You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using tempfile.TemporaryFile a ResourceWarning should be emitted with the source tracing back to user code. Instead it currently traces back to the _io.open invocation inside the tempfile module and is useless for tracking down the code that created the tempfile.
Note that it's pointing at the tempfile module itself which is worthless other than to tell me it's a tempfile that's causing the issue - however for me it's in library code and I have no idea which library!
Please modify tempfile to properly track the source and emit a better warning.
The text was updated successfully, but these errors were encountered:
The documentation says that you can pass a number to PYTHONTRACEMALLOC which is the maximum number of frames it stores. Using PYTHONTRACEMALLOC=1 stores just 1 frame.
With PYTHONTRACEMALLOC=3 (or higher), you should see the full trace:
Confirmed this is working for me to track down those leaks - I had no idea that this was possible with the tracemalloc config. I'm going to close this issue. Thank you @tomasr8!
Feature or enhancement
When using
tempfile.TemporaryFile
aResourceWarning
should be emitted with the source tracing back to user code. Instead it currently traces back to the_io.open
invocation inside thetempfile
module and is useless for tracking down the code that created the tempfile.Pitch
Take the following
foo.py
:I would expect the
ResourceWarning
to point to the linefp = tempfile.TemporaryFile()
. Instead I see the following:Note that it's pointing at the tempfile module itself which is worthless other than to tell me it's a tempfile that's causing the issue - however for me it's in library code and I have no idea which library!
Please modify
tempfile
to properly track the source and emit a better warning.The text was updated successfully, but these errors were encountered: