STINNER Victor <[email protected]> added the comment:
The socket.socket (Python type) has a private _io_refs counter. close() does
nothing until _io_refs reachs zero.
Maybe we can develop an API to temporary increase the _io_refs counter to
prevent a real close?
Pseudo-code:
@contextlib.contextmanager
def dont_close_socket(sock):
assert not sock._closed
sock._io_refs += 1
try:
yield sock
finally:
sock._io_refs -= 1
It may be a context manager or a new object. It would probably be better to put
in the socket.socke type, since it uses private attributes.
----------
nosy: +haypo
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32038>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com