[Stackless] Tasklet cleanup?
gcolgate at gmail.com
Sun May 20 06:09:38 CEST 2012
I may be mistaken, but I believe the *kill* method is called on the tasklet
during garbage collection.
You can clean stuff up in that, but you are not allowed to raise any
On Sat, May 19, 2012 at 3:29 PM, Sylvain Prat <sylvain.prat at gmail.com>wrote:
> I'm wondering how tasklets can clean themselves up when they are
> destroyed due to garbage collection (i.e. when they are not in the
> runnables and not referenced by any object anymore). Greenlet solves
> this problem by raising a GreenletExit exception in the greenlet's run
> function when the greenlet is about to die due to garbage collection.
> However, in stackless, it seems that no TaskletExit exception is
> raised when the tasklet is about to die, so we can't simply use a
> try/finally in the tasklet's callable to clean up resources.
> I tried to wrap my tasklet in a parent object which has the same
> lifespan as my tasklet and has a __del__ function for cleaning up, but
> I keep having problems with circular references (the wrapper/parent
> object also provides the callable of the tasklet, i.e. a bound method)
> that make the tasklet/parent object uncollectable (circular references
> : wrapper --> tasklet --> stackless machinery? --> callable stack
> frame (bound method of wrapper) --> wrapper). Same problem when trying
> to inherit from tasklet.
> So, how can I clean up resources in tasklets? (I'm pretty sure I've
> missed something obvious)
> Thank in advance,
> Sylvain PRAT
> Stackless mailing list
> Stackless at stackless.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Stackless