[Stackless] Advice on Writing a Stackless Reactor for Twisted
radix at twistedmatrix.com
Tue Jan 16 17:03:11 CET 2007
On 1/16/07, David Wyand <TheHeadGnome at gnometech.com> wrote:
> From: "Christopher Armstrong" <radix at twistedmatrix.com>
> > It doesn't look like this does anything that a simple
> > twisted.internet.task.LoopingCall(ReactorTick).start(0) wouldn't do.
> > If you used that much simpler technique, you also wouldn't restrict
> > yourself to the select reactor.
> I'm certainly new at this so any guidance is greatly appreciated, although I
> don't want to hijack Andrew's original query.
> In reading the API docs for t.i.task.LoopingCall() it sounds like this
> relies on the Twisted application loop being the driver rather than Twisted
> itself being treated as a tasklet and 'ticked' elsewhere. Would your code
> fragment above not require a stackless.tasklet() call somewhere to make
> Twisted go along with the uthread-like application loop I've implemented in
> my maintest.py? Or have I just completely misunderstood?
> When I approached this problem I saw that two different paths could be
> taken. The first would be to allow Twisted to be the driver and wrap all
> tasklets as deferreds (the approach I understand you've taken). The second
> is to treat Twisted as just another tasklet along with all my other network,
> GUI, and game tasklets, which is what I've posted. However I've not yet
> gone down either path far enough other than some basic AI simulations to
> discover any potential pitfalls.
What you're relying on is blocking the mainloop between calls to
'simulate'; my proposed change simply changes the blocking to be
slightly deeper down inside the reactor. The blocking will still
happen. Try it out.
International Man of Twistery
Stackless mailing list
Stackless at stackless.com
More information about the Stackless