[issue31520] ResourceWarning: unclosed <socket.socket [closed] fd=3, ...> warning

Martin Panter report at bugs.python.org
Mon Sep 25 08:07:00 EDT 2017


Martin Panter added the comment:

I’m curious how you manage to trigger the warning in the “closed” state. The Python I have handy is half a year out of date, but all my attempts to trigger the warning either produce the less confusing version,

ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 0)>

or there is no warning at all due IOBase.__del__ (see Issue 19829).

If your SocketIO was wrapped in a BufferedReader/Writer/RWPair, then that could easily close the SocketIO object before SocketIO.__del__ is called. You would also have to override the wrapper’s __del__ method, rather than (or as well as) SocketIO.__del__.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31520>
_______________________________________


More information about the Python-bugs-list mailing list