[Stackless] Problems with removing tasklet.
Jeff Senn
senn at maya.com
Wed Oct 9 14:51:49 CEST 2002
Håvard Engum <Havard.Engum at idi.ntnu.no> writes:
> Hello!
>
> I have been having problems with removing tasklets that are running.
...
> Does anyone know a solution for this?
I am doing this:
def remove_current_tasklet():
cur = stackless.getcurrent()
tmp = cur.setatomic(1)
try:
x=stackless.tasklet(lambda x: x.remove())(cur)
x.setatomic(1)
x.run()
finally:
cur.setatomic(tmp)
Basically create another tasklet to remove the current one -- the
atomic stuff just makes sure that the yield is direct (i.e. nothing
else can intervene). This is necessary since I am pre-emptively
scheduling -- it is simpler in the case of voluntary scheduling:
stackless.tasklet(lambda x: x.remove())(stackless.getcurrent()).run()
--
-Jas -------------------- www.maya.com
Jeff Senn | / / |-/ \ / /|®
Chief Technologist | /|/| |/ o | /-|
Head of R&D | Taming Complexity®
_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless
More information about the Stackless
mailing list