[Twisted-Python] A Solution Re: [Stackless] Advice on Debugging Stackless/Twisted Problem

glyph at divmod.com glyph at divmod.com
Fri May 11 18:55:31 EDT 2007


On 05:39 pm, andrewfr_ice at yahoo.com wrote:
>(When I have time, I will write a proper reactor. This
>should be a little more than overriding the
>doIteration() method of selectReactor). Or re-read the
>Blocking demo : I don't quite understand how it works)

I've said it before and I'll say it again.  Writing a reactor is the 
_wrong_ way to attempt to integrate Twisted and stackless.  Reactors are 
implemented to implement operating system or platform multiplexing 
technologies, and stackless does not have its own multiplexor. 
Multiplexing technologies are things like kqueue, epoll, IOCP, 
WaitForMultipleObjects, and AIO: APIs that allow you to wait for 
multiple input/output sources (including the clock) at the same time.

The issue is confused somewhat by GUI toolkits, which have their own 
event loops that wrap these APIs, so we have a few things that use those 
reactors as a back-end to cooperate in the most friendly way possible 
with those GUIs, but ultimately what Twisted is talking to in GUI 
libraries is another multiplexing API.

Stackless does not have any such API, and nor should it.  Making a 
stackless reactor would needlessly couple stackless/twisted integration 
to a particular multiplexor.  For example, it would make it impossible 
to write an application which used both GTK and Stackless.  Also, you'd 
need to choose either a portable, but inefficient and non-scalable API 
(like select) or a highly performant, but highly platform-specific API 
(like kqueue).  This is a decision that should be made when an 
application is deployed, and only required by an application developer 
if they are using platform-specific features (which stackless is not).

I keep hearing this idea of a "stackless reactor" bandied about, and I 
don't know how I can make this any more clear.  Again I refer to my 
original post on the subject:

    http://article.gmane.org/gmane.comp.python.twisted/13946
>1) Eliminate a OS-Thread (both Stackless and Twisted
>folks concur that this is wrong, wrong, wrong).

Notwithstanding the above, I'm glad that you've eliminated this.  It's a 
step in the right direction.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20070511/463b8883/attachment.htm 


More information about the Twisted-Python mailing list