[Stackless] Tasklet Slot Inheritance

Richard Tew richard.m.tew at gmail.com
Sun May 20 15:47:29 CEST 2007

On 5/9/07, Edward Faulkner <ef at alum.mit.edu> wrote:
> I've noticed a weird behavior when I inherit from tasklet.  If my
> class doesn't define __slots__, I can define and use extra member
> variables as expected, and they remain valid for the life of the
> object.
> But if I define __slots__ to limit the possible member variables, they
> get deleted when the tasklet exits, even though I still have a
> reference to it.

When a tasklet is killed, it has its references cleared through the
tp_clear method.  This is part of the Python type implementation and
clears various references in order to prevent or break reference
cycles.  Including, as observed here, the slots.

I do not think it is critical that this call be made by Stackless, but
I also do not think that it being called (and the observed
side-effects it may cause) is necessarily a bug.  My take is that it
is reasonable for this call to be made when a tasklet exits, and it is
also reasonable that anyone holding references to dead tasklets should
not expect that they have the state they had while running.
Admittedly in the case of slots, this is a little inconvenient.

Removing this call does not break any of the Stackless unittests.  But
I think making it has obvious benefits in preventing leakage.

Any thoughts anyone?


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list