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 yselivanov
Recipients Ben.Darnell, asvetlov, gvanrossum, pitrou, vstinner, yselivanov
Date 2017-11-16.16:34:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510850098.49.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.

I didn't know about this.  Looks like I can use '_io_refs' to fix some problems in uvloop, thanks Victor!

The only problem with '_io_refs' and `dont_close_socket` approach is that the original intent to close the socket is "lost".  Consider this example:

  fut = loop.sock_recv(sock)
  sock.close()
  await fut

Ideally, I'd expect `sock` to be closed right after `await fut` is completed.  One way to make that possible is to initialize socket object with 'self._io_refs = 1', not 0.  Whenever it goes to 0, the socket gets closed.  This is a slight change to the existing machinery, but it would make sock.close() more predictable.
History
Date User Action Args
2017-11-16 16:34:58yselivanovsetrecipients: + yselivanov, gvanrossum, pitrou, vstinner, asvetlov, Ben.Darnell
2017-11-16 16:34:58yselivanovsetmessageid: <1510850098.49.0.213398074469.issue32038@psf.upfronthosting.co.za>
2017-11-16 16:34:58yselivanovlinkissue32038 messages
2017-11-16 16:34:58yselivanovcreate