[Stackless] Advice on Writing a Stackless Reactor for Twisted
andrewfr_ice at yahoo.com
Wed Jan 10 23:46:30 CET 2007
I also posted this on the Twisted mailing list....
For the past few months I have been experimenting with
using Stackless Python with Twisted. I still consider
myself very much a Twisted newbie. Currently my
problems involve deferreds.
>From doing online searches, I have run across
customized reactors for Twisted. Consequently I am
looking at the custom reactors that come with Twisted.
Like Stackless, many GUIs have a hard time working
with Twisted which blocks. Based on the
ThreadedSelectReactor, most of the reactors are for
GUIs. The general idea is that custom reactor's event
loop calls Twisted in its own thread. This approach
seems like it would work for Stackless and provide a
decent general solution. However there are a few
places where I am not quite clear.
Most of my Stackless programmes have the following
form (think of this as a MainLoop):
set up stuff
while (stackless.getruncount() > 1):
Since it seems my custom reactor has to call Twisted
as often as possible. I would wrap
stackless.schedule() (since this is often called):
__hook__() # some method that would call Twisted
Where I start to get a bit confused is:
1) In the Custom reactor.run() method, do I call
self.__hook__() in the interleave() method? Is there
anything more I have to do in the run() method? Can I
avoid signal handler issues by passing False to
Twisted's reactor.run() ?
2) From my Stackless code, do I have to use
self.callFromThread() to call Twisted methods that
Again, any advice would be welcomed.
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
Stackless mailing list
Stackless at stackless.com
More information about the Stackless