[issue35840] Control flow inconsistency on closed asyncio stream

Marc Schlaich report at bugs.python.org
Mon Jan 28 02:54:06 EST 2019


New submission from Marc Schlaich <marc.schlaich at googlemail.com>:

After closing a StreamWriter the `StreamReaderProtocol.connection_lost` on the other end is not getting called. In this case the StreamReader is at EOF but calling write/drain does not raise any Exception (and sending data to Nirvana). 

I would expect that StreamWriter.is_closing returns True after the close and calling write/drain raises immediately and not just after the second call. Please see attached example. I see the same behavior with Proactor and Selector event loop on Windows.

Maybe this is expected behavior. But in this case it is completely undocumented. Should there be a check for `StreamReader.at_eof` (and maybe `StreamReader.exception`) before writing to the StreamWriter?

This might be related to bpo-34176.

----------
components: asyncio
files: tcp_test.py
messages: 334450
nosy: asvetlov, schlamar, yselivanov
priority: normal
severity: normal
status: open
title: Control flow inconsistency on closed asyncio stream
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48082/tcp_test.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35840>
_______________________________________


More information about the Python-bugs-list mailing list