Re: [Twisted-Python] Question about Writing a Stackless Friendly Reactor
Hello Glyph:
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 not run. 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. http://code.google.com/p/stacklessexamples/wiki/StacklessTwisted 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 printing immediately. 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 approaches.
I recently replied to a very similar question in a different thread:
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. Cheers, Andrew ____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091
participants (1)
-
Andrew Francis