asyncio icon indicating copy to clipboard operation
asyncio copied to clipboard

spurious ConnectionAbortedError logged on Windows

Open sbourdeauducq opened this issue 9 years ago • 7 comments

On Windows, asyncio servers sometimes print such log messages when clients disconnect:

ERROR:master:asyncio:Fatal write error on pipe transport
protocol: <asyncio.streams.StreamReaderProtocol object at 0x0000000003F63FD0>
transport: <_ProactorSocketTransport fd=756>
Traceback (most recent call last):
  File "C:\Users\User\Miniconda3\lib\asyncio\proactor_events.py", line 283, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
  File "C:\Users\User\Miniconda3\lib\asyncio\windows_events.py", line 450, in send
    ov.WSASend(conn.fileno(), buf, flags)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software on your host machine.

I guess that this line: https://github.com/python/asyncio/blob/39c135baf73762830148236da622787052efba19/asyncio/proactor_events.py#L291

should be changed to also catch ConnectionAbortedError, as this exception also happens when connections are closed on Windows, in addition to ConnectionResetError.

sbourdeauducq avatar Feb 18 '16 15:02 sbourdeauducq

Making the change I suggested solves my problem and from cursory testing indicates it does not introduces any issues. Thoughts?

sbourdeauducq avatar Feb 21 '16 18:02 sbourdeauducq

I don't know the first thing about the Windows code (and have no way to test it) but it looks like a reasonable hypothesis. Could you submit a PR with a unit test that proves that it works?

gvanrossum avatar Feb 22 '16 19:02 gvanrossum

@haypo you wrote that code, what do you think of the change?

sbourdeauducq avatar Feb 23 '16 03:02 sbourdeauducq

http://bugs.python.org/issue26509

sbourdeauducq avatar Mar 08 '16 04:03 sbourdeauducq

I attached a patch on the Python issue.

vstinner avatar Mar 08 '16 10:03 vstinner

Your patch seems to miss the _fatal_error method in proactor_events.py (which is actually where the bug happens in my application - it's using ProactorEventLoop).

sbourdeauducq avatar Mar 08 '16 15:03 sbourdeauducq

Let's keep the conversation in the Python issue tracker.

sbourdeauducq avatar Mar 10 '16 04:03 sbourdeauducq