[New-bugs-announce] [issue26278] BaseTransport.close() does not trigger connection_lost()

Sümer Cip report at bugs.python.org
Wed Feb 3 10:57:36 EST 2016


New submission from Sümer Cip:

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,

----------
components: asyncio
messages: 259487
nosy: Sümer.Cip, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: BaseTransport.close() does not trigger connection_lost()
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26278>
_______________________________________


More information about the New-bugs-announce mailing list