[Stackless] [threading] Stackless based replacement
dragonsa at highveldmail.co.za
Fri Sep 26 15:50:09 CEST 2008
On Friday 26 September 2008 15:11:00 Jeff Senn wrote:
> On Sep 26, 2008, at 8:04 AM, David Naylor wrote:
> > Just a few questions:
> > 1) Under what conditions does atomic not work?
> Hm. I thought you meant *your* atomic didn't work. We should really
> be worried
> (well, me, at least!) if .set_atomic doesn't work! Can you generate
> a test case?
My atomic is based on .set_atomic, and there should not be any explicit
passing of control. I compensated for it [the apparent bug?] by forcing a
reschedule until the correct tasklet came about...
Unfortunately my code that generates this problem is FreeBSD based and will
only work with FreeBSD Ports (If you have I will gladly send you the code).
> [I didn't look at all your code carefully... it's not clear to me how/
> if you are
> doing automatic scheduling. ...Oh... Did you read
> carefully? .set_atomic does
> only stop *automatic* switching of control... explicit passes (e.g.
> send) can
> still "switch" tasklets...]
I didn't read that carefully, but it should not be a problem. Yes I am using
automatic scheduling (with run(1000))
> > 2) Will stackless switch to another tasklet when entering blocking
> > routines
> > (like IO), I know threads do this...
> No it won't. In fact, it fundamentally *can't* (since it "runs" in
> only one thread).
Surely there is a way around this? Some kind of pooling select? If there is
no work around then I cannot see too much practical use for my thread library
[except having to avoid learning tasklets for someone who is familiar with
threads]. As I understand it, due to the GIL the only real practical use for
threads is if one has blocking function calls (IO-type, etc)
[Has the GIL restriction been fixed in 3k? As far as I know Jython does not
have this limitation...]
> > 3) Does anyone know where to find how many commands python processes
> > before it
> > tries to switch threads (I remember something like that happening?)
> It's not really "commands"... more like a number of loops through the
> code interpreter.
> Did you mean "threads" or "tasklets"?
> If you meant "threads" the answer is complicated... if you meant
> then see the parameter to stackless.run.
I asked because I remember somewhere that python does a 'switch' every X
lines... I just wanted to pass the same number to run().
> print stackless.run.__doc__
More information about the Stackless