[Twisted-Python] Stackless/Twisted integration again

Jean-Paul Calderone exarkun at divmod.com
Sun Apr 6 09:08:13 MDT 2008


On Sun, 06 Apr 2008 10:39:08 +0100, Simon Pickles <sipickles at hotmail.com> wrote:
>I was interested in Andrews Paper on this subject. I note he recommends 
>running a twisted server as a tasklet.
>
>Is there a problem doing this?
>
>factory = pb.PBClientFactory
>reactor.connectTCP('127.0.0.1', 1234, Factory)
># Load other tasklets here
>stackless.tasklet(reactor.iterate)(1)
>
>or should I perhaps do this?
>
>factory = pb.PBClientFactory
>reactor.connectTCP('127.0.0.1', 1234, Factory)
># Load other tasklets here
>while 1:
>    stackless.tasklet(reactor.iterate)(1)
>    stackless.schedule()
>
>What does the delay in reactor.iterate(delay=0) do? Is there a 
>reactor.run_once() call?
>
>I want to make the reactor a tasklet so it is included in the scheduler. 
>Seems to be working but have I opened a can of worms?
>

Most or all uses of reactor.iterate() are wrong.  I don't think Andrew's
paper suggested doing this.  Why did you decide to?

Jean-Paul




More information about the Twisted-Python mailing list