This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Ben.Darnell, asvetlov, gvanrossum, pitrou, vstinner, yselivanov
Date 2017-11-16.16:24:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510849480.59.0.213398074469.issue32038@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-11-16 16:24:40vstinnersetrecipients: + vstinner, gvanrossum, pitrou, asvetlov, Ben.Darnell, yselivanov
2017-11-16 16:24:40vstinnersetmessageid: <1510849480.59.0.213398074469.issue32038@psf.upfronthosting.co.za>
2017-11-16 16:24:40vstinnerlinkissue32038 messages
2017-11-16 16:24:40vstinnercreate