Message306370
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. |
|
Date |
User |
Action |
Args |
2017-11-16 16:24:40 | vstinner | set | recipients:
+ vstinner, gvanrossum, pitrou, asvetlov, Ben.Darnell, yselivanov |
2017-11-16 16:24:40 | vstinner | set | messageid: <1510849480.59.0.213398074469.issue32038@psf.upfronthosting.co.za> |
2017-11-16 16:24:40 | vstinner | link | issue32038 messages |
2017-11-16 16:24:40 | vstinner | create | |
|