[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)
    x=stackless.tasklet(lambda x: x.remove())(cur)

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

More information about the Stackless mailing list