[Stackless] Weakref support for tasklets

Bob Ippolito bob at redivi.com
Thu Jan 29 09:27:15 CET 2004


I'm committing weakref support for tasklets, because I have a need for 
it (giving each tasklet a separate stdin/stdout/stderr by using proxy 
objects with __getattr__, since I can not give them separate sys 
modules).  I'm not 100% of the ramifications of this, but it was about 
a four line change and it doesn't seem to cause any problems (though it 
does show how tasklets can be a little odd).

Additionally, would it be useful to put a weakref slot on channels?  I 
don't need that at the moment, but it might be useful to someone?

 >>> import weakref, stackless
[25312 refs]
 >>> t = stackless.tasklet(lambda: None)()
[25336 refs]
 >>> def t_finalize(t): print t
...
[25357 refs]
 >>> t_ref = weakref.ref(t, t_finalize)
[25362 refs]
 >>> del t
[25361 refs]
 >>> stackless.run()
<weakref at 0xce7d0; dead>
[25339 refs]
 >>> t = stackless.tasklet(lambda: None)()
[25360 refs]
 >>> t_ref = weakref.ref(t, t_finalize)
[25361 refs]
 >>> stackless.run()
[25359 refs]
 >>> del t
<weakref at 0xd8158; dead>
[25339 refs]

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
URL: <http://www.stackless.com/pipermail/stackless/attachments/20040129/7f78fbc9/attachment.bin>
-------------- next part --------------
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless


More information about the Stackless mailing list