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 Sümer.Cip
Recipients Sümer.Cip, gvanrossum, vstinner, yselivanov
Date 2016-02-03.15:57:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454515056.72.0.0290408111031.issue26278@psf.upfronthosting.co.za>
In-reply-to
Content
Hi all,

We have implemented a TCP server based on asyncio. And while doing some regression tests we randomly see following error:

1) Client connects to the server.
2) Client is closed ungracefully(without sending a FIN, deplug cable)
3) We have a custom PING handler that sends a PING and waits for PONG message.
4) After a while, we see that we timeout for the PING and we call close() on the Transport object. 

Now, most of the time, above just works fine, but at some point, somehow connection_lost() is NEVER gets called even though we call close() on the socket. As this issue is happening very randomly I don't have any asyncio logs for it. But can you think about any scenario that might lead to this somehow? 

Somehow, it seems we have an outgoing data in the TCP buffer when this happens and that is why the close() does not call the connection_lost immediately, but why it is never calling it is a mystery to me. Can that be following:

1) we call close() and is_closing is set to true we have outgoing data so we return.
2) Then a subsequent write occurs and connection ConnectionResetError() is raised and this calls _force_close(), but as we have previously set is_closing to True, connection_lost() does not get called.

Above is just a very trivial idea which is probably is not the case, I do not spend too much time on the code. 

Thanks,
History
Date User Action Args
2016-02-03 15:57:36Sümer.Cipsetrecipients: + Sümer.Cip, gvanrossum, vstinner, yselivanov
2016-02-03 15:57:36Sümer.Cipsetmessageid: <1454515056.72.0.0290408111031.issue26278@psf.upfronthosting.co.za>
2016-02-03 15:57:36Sümer.Ciplinkissue26278 messages
2016-02-03 15:57:36Sümer.Cipcreate