You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2014-08-27.16:29:53.358>created_at=<Date2011-02-21.05:54:31.497>labels= ['invalid', 'type-bug', 'library', 'expert-IO']
title='asyncore does not check for POLLERR and POLLHUP if neither readable nor writable'updated_at=<Date2014-08-27.16:29:53.355>user='https://github.com/socketpair'
ifflags:
# Only check for exceptions if object was either readable# or writable.flags |= select.POLLERR|select.POLLHUP|select.POLLNVALpollster.register(fd, flags)
This is unexpected behaviour. Why descriptor does not get polled if neither read nor write selected ? So I can not track dropping of connection if I do not want neither read nor write. I think "if flags:" should be removed.
Why descriptor does not get polled if neither read nor write selected ?
IMO it's a deliberate design choice, made for performances.
In the asyncio module, the high-level StreamReader API stops listening to read even if the buffer is too large (if we received more than limit*2 bytes, where limit is 64 KB by default). We listen again when the application reads enough data from the buffer.
When we stop listening to read event (and we don't listen to write events neither), we ignore completly the socket. So if the socket is closed, we are not notified immediatly. IMO it's a design choice for efficency. It's more efficient to ignore temporarily the socket while the application is busy, than notifying immediatly that the connection was closed.
In my test, I still got some bytes with socket.recv() even after the connection was already closed by the peer.
Pseudo-code:
client: connect
client: recv(10): get some bytes
server: close the connection
client: recv(10): get more bytes (even if the connection was already closed)
client: notified that the connection was closed
I don't think that asyncore nor asyncio should be modified to be notified immediatly that a connection was closed, so I close the issue.
Thanks for your report, it was an interesting question :-)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: