[Python-Dev] microthreading vs. async io

Joachim König-Baltes joachim.koenig-baltes at emesgarten.de
Thu Feb 15 15:49:09 CET 2007


Adam Olsen wrote:
> I agree with everything except this.  A simple function call would
> have O(n) cost, thus being unacceptable for servers with many open
> connections.  Instead you need it to maintain a set of events and let
> you add or remove from that set as needed.
We can learn from kevent here, it already has EV_ADD,
EV_DELETE,  EV_ENABLE, EV_DISABLE, EV_ONESHOT
flags. So the event-conditions would stay "in the scheduler" (per task)
so that they can fire multiple times without the need to be handled
over again and again.

Thanks, that's exactly the discussion I'd like to see, discussing about
a simple API.

>> I have implemented something like the above, based on greenlets.
>
> I assume greenlets would be an internal implementation detail, not
> exposed to the interface?
Yes, you could use stackless, perhaps even Twisted,
but I'm not sure if that would work because the requirement for the
"reads single-threaded" is the simple wait(...) function call that does 
a yield
(over multiple stack levels down to the function that created the task),
something that is only provided by greenlet and stackless to my knowledge.

Joachim



More information about the Python-Dev mailing list