[Twisted-Python] Stackless/Twisted integration again
Simon Pickles
sipickles at hotmail.com
Sun Apr 6 09:49:37 MDT 2008
Jean-Paul Calderone wrote:
> 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.
How should it be used? It looks to be working very successfully so far.
The docs say "All pending |IDelayedCall|
<http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IDelayedCall.html>s
will be called."
Does this not mean the reactor will process its queue and return? I
imagine the delay argument specifies a maximum duration before the
return. The docs do not describe this yet.
> I don't think Andrew's paper suggested doing this. Why did you decide
> to?
>
I want a way to let twisted.reactor yield to the stackless scheduler.
Thanks for any advice
Simon
More information about the Twisted-Python
mailing list