[Stackless] threading.local analogue to tasklets

Richard Tew richard.m.tew at gmail.com
Thu Jun 21 11:32:57 CEST 2007

On 6/21/07, Arnar Birgisson <arnarbi at gmail.com> wrote:
> On 6/21/07, Richard Tew <richard.m.tew at gmail.com> wrote:
> > There is no atomic anymore :-)
> Ah, sorry - my bad. I meant to be referring to stackless.tasklet.set_atomic:
> import stackless
> currentTasklet = stackless.getcurrent()
> atomic = currentTasklet.set_atomic(True)
> try:
>     print "Executing critical section"
> finally:
>     currentTasklet.set_atomic(atomic)
> Just wondering if it will hurt to do that if the cooperative scheduler is used.

No idea.  I would assume that it wouldn't, but I have never used it or
had a case to look into how exactly it works.

In my experience with cooperative scheduling you always know when you
are going to block because you have to be prepared to deal with
whatever change in circumstances may have occurred when you are
rescheduled.  In which case the knowing what code is implicitly atomic
or not does away with any need to use something like set_atomic as a
matter of course.


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list