[Twisted-Python] a problem about iocp and callInThread
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Sun May 15 12:29:16 EDT 2011
On 04:10 pm, dynamicgl at gmail.com wrote:
>Hi all
>
> I just encountered a problem about iocp reactor & callInThread. I
>paste the code following:
>
>from twisted.internet import iocpreactor
>iocpreactor.install()
>from twisted.internet import reactor
>
>class ThreadTest:
> def __init__(self,name):
> self.count = 0
> self.max = 5
> self.wait = 1
> self.name = name
>
> def __call__(self):
> self.Execute()
>
> def Execute(self):
> print self.name, time.time()
> self.count += 1
> if self.count <self.max:
> reactor.callLater(self.wait, reactor.callInThread,
>self.Execute)
> else:
> print self.name, "stop"
>
>reactor.callInThread(ThreadTest("test"))
>
>the problem is every time the print method was invoked, i noticed that
>the difference between current invoke and previous invoke was 2
>seconds. In theory ,it should be one second. When i used the plain
You're calling reactor.callLater from a non-reactor thread. This isn't
supported and will produce unpredictable behavior.
Jean-Paul
>reactor (which means no iocpreactor), the difference was one second
>which is a correct value.
>
>I want to know what makes callInThread so special with iocpreactor?
>
>BTW: i used windows 7 & window s2008.
>
>Regards
>
>gelin yan
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list