[Stackless] pause execusion of tasklet using remove()

Christian Tismer tismer at stackless.com
Sat Oct 14 00:42:35 CEST 2006

Jimsfba at aol.com wrote:


> When looking at the remove() api, I saw the following warning message 
> about it:
>      |  remove(...)
>      |      Removing a tasklet from the runnables queue.
>      |      Note: If this tasklet has a non-trivial C stack attached,
>      |      it will be destructed when the containing thread state is 
> destroyed.
>      |      Since this will happen in some unpredictable order, it may 
> cause unwanted
>      |      side-effects. Therefore it is recommended to either run 
> tasklets to the
>      |      end or to explicitly kill() them.
> Does it mean it's not recommended to use remove() if I am not sure about 
> if non-trivial C stack has been attached ?

Yes. This C state may contain necessary data for closing the
channel, for instance. It may keep system resources.
Stackless cannot know this, and in order to give you full
pow(d)er, it assumes you know what you are doing when you don't
protect this data from being collected.

> If anyone can explain what is "containing thread" ( for example, is it a 
> thread generated by stackless internally ?  the main watchdog thread or 
> the calling function of python?) and give an example how remove() might 
> failed, I will really appreciate.

The containing thread is nothing special. It is up to you to
create threads. Every tasklet is bound to its thread, if it
has a non-trivial C state. Other tasklets can float.
And if such a thread is created for one of your
tasklets, then your tasklet will remember the thread state
and will only run in this thread. And if you have state attached
and let the thread die, then you are at your own risk.

Remove() does not fail. But it is a failure to remove()
a tasklet without letting it run to the end, unless you
know this is harmless. Soft-switched tasklets are known
to be harmless, others are by default not.

That's all, folks
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list