Yury Selivanov <yseliva...@gmail.com> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32038>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to