STINNER Victor added the comment:

> 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 :-)

----------
nosy: +haypo
resolution:  -> not a bug
status: open -> closed

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

Reply via email to