[Stackless] An idea for making Stackless more naturally usable
richard.m.tew at gmail.com
Sun Sep 10 11:00:05 CEST 2006
On 9/9/06, Andrew Dalke <dalke at dalkescientific.com> wrote:
> > In any case, while I believed that Stackless supported
> > an isolated scheduler per thread, I did not care to go out on
> > a limb and say as much, so I wrote up an example to
> > demonstrate that this does work:
> > http://svn.python.org/view/stackless/sandbox/examples/
> > threadscheduling.py?view=markup
> Thanks. Glad to know it works.
> quoting from that:
> > # ... which is why I need to start a ManageSleepingTasklets for each of
> > # them.
> Hence asyncore also needs its own per-thread scheduler via it's own
This example was just written to show that the scheduler for each
thread is independent. If you take into account that channels
should be able to send and receive (although I have never used
this functionality) between tasklets on different threads, then
it should be possible to write a 'ManageSleepingTasklets' which
runs on one thread and works for them all.
But I have no example to prove this, and as I say I have not
used threading much if at all, so I guess it would be best to
write one to prove it.
However, as you point out in your last mail, it needs to work
together with asyncore to prevent the cpu from being at 100%.
I assume that all threads would need to use this form of
blocking anyway, so that none of them caused the cpu to be
at 100%. Do you know if this is right?
> > Also, I started the monkeypatching module based on your
> > outline:
> > http://svn.python.org/view/stackless/sandbox/libraries/slpmonkeypatch/
> I see you mention a
> I would like to expand that to
> which provides stackless-safe versions of blocking code from
> the corresponding system libraries.
> They may need to go through a
> which looks like
> # keep references to the original objects, before monkeypatching
> import sys
> import socket
> file = __builtin__.file
> so other modules can do
> from stackless.std import socket as stdsocket
> (When I say "like" I don't mean it needs to be these exact details.)
But it is as good a way as any to start off :) If you haven't done so
I'll look into this when I have the Windows stuff working or
when I need a break from it.
Stackless mailing list
Stackless at stackless.com
More information about the Stackless