[py-dev] Re: Greenlets
Armin Rigo
arigo at tunes.org
Fri May 6 14:16:05 CEST 2005
Hi,
The greenlet description at the ACCU was a lightning talk only. Its
content is now in the greenlet documentation, as the motivating example:
http://codespeak.net/py/current/doc/greenlet.html#example
Greenlets are not garbage collected in the sense that the following kind
of cycle isn't detected and will leak:
object in your program ----------> greenlet object
greenlet object ---internal ref---> suspended frame
suspended frame ---local variable---> object in your program
Only the second link misses a proper C-level tp_visit. It could be
implemented by looking at the frame chain of the greenlet object and
calling visit() on each frame, thus meaning that the greenlet object
implicitely holds a reference to each of these suspended frames. This
would probably help in the common case described above. In reality, the
greenlet object has a reference to a bunch of bytes that have been
copied verbatim from a part of the C stack; while it is probably safe to
assume that this C stack contains one reference to each of the suspended
frame, it might contain more references to other objects, and it's
almost impossible to know that.
A bientot,
Armin.
More information about the Pytest-dev
mailing list