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