[Stackless] Tasklet clean up

Richard Tew richard.m.tew at gmail.com
Sun Apr 29 10:17:01 CEST 2012


On Sun, Apr 29, 2012 at 6:09 PM, Fernando Miranda <fcmiranda at gmail.com> wrote:
> Hello, I'm not sure if this has sense but I'm wondering if Stackless
> 'clean ups' all tasklet resources when tasklets die.
> For example, suposse a tasklet that opens files and/or sockets, will
> those resources be automatically  closed when the tasklet die? Can
> that be done easily?

Hi Fernando,

You're using Python, it comes down to how you hold your references.
It doesn't matter if you are using Stackless or not.  If you create
files and sockets in a tasklet, then pass references to those objects
(or objects that refer to those objects) out of the tasklet, then
you're keeping them alive yourself.  Otherwise, when the tasklet exits
the objects should be cleaned up through normal Python processes.

To be clear.  Stackless does not do anything magical keeping track of
resources.  If you're leaking objects and resources are not being
closed, YOU are doing it wrong :-)  So.. don't do it wrong, use weak
references when applicable.. etc with standard Python approach that
applies whether using Stackless or not.

Cheers,
Richard.



More information about the Stackless mailing list