This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improved generator finalization
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: pje Nosy List: pje, tim.peters, twouters
Priority: normal Keywords: patch

Created on 2006-04-03 22:43 by pje, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
genfinalize.patch pje, 2006-04-05 20:06 Patch for generator finalization change
Messages (5)
msg49954 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2006-04-03 22:43
This patch improves generator finalization such that
simple generators (without active try/except/finally
blocks surrounding yield statements) can have their
cycles broken.

Please check to see if this patch improves the leaks
that prompted the request for changing this.  Thanks.
msg49955 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-04-05 19:25
Logged In: YES 
user_id=31435

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file. In addition, even if you
*did* check this checkbox, a bug in SourceForge
prevents attaching a file when *creating* an issue.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )
msg49956 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2006-04-05 20:06
Logged In: YES 
user_id=56214

Argh.  Sorry.  Uploaded.
msg49957 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2006-04-09 15:02
Logged In: YES 
user_id=34209

The patch looks alright (although it could use some big
blinking comments in opcode.h and ceval.c, to make sure
PyGen_NeedsFinalizer is properly updated when new block
types are added.) The patch fixes the
test_generators_cycle.py leaker-test, but it does *not* fix
the cycles test_generators test. (Obviously after removing
the code that explicitly breaks the cycle in test_generators.)

I don't know why it doesn't clean up the test_generators
cycle. Maybe it's related to doctest, or the way doctests run.
msg49958 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2006-04-10 17:53
Logged In: YES 
user_id=56214

Checked in as of r45235, w/added comment to ceval.c.

If the test that's leaking doesn't leave a generator
suspended in a 'with', try/except, or try/finally block,
then a reference is probably being held somewhere that makes
it not garbage yet.  (Or perhaps it's being referenced by an
object w/a __del__ method?)  Let me know what you find out.
History
Date User Action Args
2022-04-11 14:56:16adminsetgithub: 43153
2006-04-03 22:43:11pjecreate