[Stackless] pause execusion of tasklet using remove()
richard.m.tew at gmail.com
Fri Oct 13 11:38:16 CEST 2006
On 10/13/06, Jimsfba at aol.com <Jimsfba at aol.com> wrote:
> Does it mean it's not recommended to use remove() if I am not sure about if
> non-trivial C stack has been attached ?
> 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.
Threads each have their own chain of tasklets which are scheduled on
them. These are independent, although you can communicate between
tasklets on different threads using channels which are thread-safe.
So if you create a thread and run tasklets on it, then remove one which
has saved an area of the stack which it has used, then I imagine that
you have no guarantee that the thread won't be cleaned up before the
tasklet (the difference being that it then can't be killed as killing it
required running it raising a TaskletExit exception on it as the thread
it was scheduled on is no longer present).
So whatever the stack would have addressed if it ran to completion
(whether by raising a TaskletExit exception up through it or just
normally) will be either leaked or the cause of more serious
problems. Of course I am just hand-waving about the problems
you will encounter as I have never had to experience this myself
and do not do much C programming besides the little I do on
But. If you just use the Python main thread scheduler and do
not use threading, I think you should be pretty safe. Based on
my understanding of the Stackless code even removed
tasklets should be garbage collected before the thread is
killed (although it is probably easy to arrange a situation
where the tasklet is not garbage collected). Consider that
more handwaving. I don't have too good a memory or
much experience with all this. But I am confident is should
be the gist of it.
Hope this helps,
Stackless mailing list
Stackless at stackless.com
More information about the Stackless