[Twisted-Python] Question about Writing a Stackless Friendly Reactor
andrewfr_ice at yahoo.com
Wed Apr 11 08:56:57 EDT 2007
>I disagree. Separate reactor implementations are for
>different OS multiplexing mechanisms.
>stackless.schedule() should *not* be called
>"whenever possible", but rather, whenever stackless
>tasks have something to do.
To the best of my understanding, if one is using
Stackless cooperative scheduling, a tasklet should
yield, that is, call schedule() when it is finished
doing work. Otherwise, other tasklets that could run,
will not get an opportunity.
In a Stackless application, the reactor is running in
a tasklet. Leaving aside the issue of channels, if the
reactor does not call schedule(), other tasklets will
For most applications, the Twisted Reactor blocking
the application is not an issue since the tasklets
have nothing to do if they do not have input In the
case of my application, the blocking is an issue...
That said, we can write simple programmes to
illustrate this (or fix my first example). For
instance, I illustrate the aforementioned on the
Stackless Google code page.
In the first example, the tick tasklet will print only
after the request handler has received input. In the
second threaded example, the tick tasklet will start
I am looking for ways of getting the behaviour of the
second example without using threads (or Twisted tasks
that make schedule() calls)
>Don't implement a reactor :).
I think subclassing SelectorReactor may give me much
of what I want. I suspect this is an unTwisted way of
doing things. I am still experimenting with
>I recently replied to a very similar question in a
>What about my answer there was not clear?
I don't agree with a part of the premise. That aside,
I tried using reactor.callLater(). It didn't help.
Perhaps I am using it wrong.
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
More information about the Twisted-Python