denis.bilenko at gmail.com
Thu Nov 12 05:54:31 CET 2009
On Thu, Nov 12, 2009 at 1:46 AM, Richard Tew <richard.m.tew at gmail.com> wrote:
> It's been a long held desire to have a library available for Stackless
> that monkeypatches calls that block to the operating system and
> therefore block the interpreter and entire scheduler, with calls that
> merely block to the scheduler and therefore only block the current
> tasklet until an asynchronous IO operation completes.
> Interesting, one of the many libraries based on the Greenlet spinoff
> extension seems to have already done this.
> gevent: http://gevent.org/
> gevent monkey patching: http://gevent.org/gevent.monkey.html
I've actually been wondering for some time now whether I should add
support for stackless to gevent and how to do it.
There are a couple of things I don't quite understand though.
1. Will gevent on stackless take advantage of faster "soft" switching?
>From reading this explanation by Kristján Valur Jónsson
> 'hard switching' occurs when it becomes necessary to save the C
stack, and manipulate the stack pointer.
> Usually this is because some C code has been involved in the
tasklet, so that its state cannot be fully
> represented by just a linked chain of python frames. For example,
if python code calls some C function
> which then recursively calls into python.
it seems that it will not. That is because all switching is
orchestrated by the libevent event loop which is C code.
2. Are other features of stackless (e.g. tasklet pickling) going to
work in such arrangement?
3. Is it possible to do switching directly in Stackless, in a manner
similar to greenlet's switch() and throw() methods?
I guess I could emulate greenlet's interface with Tasklet + Channel,
but that seems like an overkill.
More information about the Stackless