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 vstinner
Recipients BreamoreBoy, giampaolo.rodola, socketpair, vstinner
Date 2014-08-27.16:29:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1409156993.37.0.0757698598428.issue11267@psf.upfronthosting.co.za>
In-reply-to
Content
> 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 :-)
History
Date User Action Args
2014-08-27 16:29:53vstinnersetrecipients: + vstinner, giampaolo.rodola, BreamoreBoy, socketpair
2014-08-27 16:29:53vstinnersetmessageid: <1409156993.37.0.0757698598428.issue11267@psf.upfronthosting.co.za>
2014-08-27 16:29:53vstinnerlinkissue11267 messages
2014-08-27 16:29:53vstinnercreate