[issue28629] Emit ResourceWarning when implicitly terminating a suspended frame?

STINNER Victor report at bugs.python.org
Mon Nov 7 03:56:04 EST 2016


STINNER Victor added the comment:

To take a decision, I would suggest to implement the warning, run the
Python test suite, and run the test suite of a few applications like
Twisted and Django, to see how much code needs to be modified.

Well, let's say that my code consumes a generator but emits the
warning because it doesn't consume completely the warning. What am I
supposed to do?

Let's say the the generator is an infine suite like (2**i for i in
itertools.count()). Should I call gen.close()?

If a generator holds a resource like a file, does gen.close()
immediately release the resource? Or does it rely on the garbage
collector?

I'm curious to see if using source=frame when emitting the warning
helps to identify quickly the origin of the bug. I added the source
parameter in Python 3.6. It requires the usage of tracemalloc to log
where the source object (the frame in this case) was allocated.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28629>
_______________________________________


More information about the Python-bugs-list mailing list