Hi all I modified my code as reactor.callFromThread(reactor.callLater, self.wait, reactor.callInThread, self.Execute)
based on your comments. now the problem have been solved. Thanks your guys. I appreciate your help. Regards gelin yan On Mon, May 16, 2011 at 12:29 AM, <[email protected]> wrote: > On 04:10 pm, [email protected] 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 > >[email protected] > >http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > _______________________________________________ > Twisted-Python mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >
_______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
