[Stackless] More on a Stackless Select
andrewfr_ice at yahoo.com
Fri Apr 16 19:08:20 CEST 2010
In previous posts, I talked about implementing a select in Stackless Python. Conceptually it is not difficult. And I still think most of a select like mechanism can and should be implemented as a module. However the more I work with the stackless.py prototype and look at C Stackless Python, I believe I was optimistic in the amount of changes required to C Stackless Python. The changes are not huge, but they are not trivial either as I originally planned. I plan to give a talk on this at the end of this month to my local Python group :-) I still need to run benchmarks that will determine if all of this is really worth it.
To date some of the difficulties:
1) blocked is overloaded to both indicate state and the operation - this has to be separated.
2) What does _channel mean when a tasklet is blocked on a selector? Should it point to a selector implementation. Should _channel become some list of channels. What would this break?
3) Select needs the most cooperation from the channel class. The particularly complicating case - selector is waiting for one or more receivers to rendezvous.
4) To avoid race conditions or really really complicated data structures, the tasklet with the selector has to be scheduled immediately. This implies that anything using a select like mechanism will run with high priority. Then again, it is acting like a dispatcher in an event loop.
Meanwhile, I am looking at Go to see how it solves these problems.
More information about the Stackless