[issue36840] Add stream.abort() async method

Andrew Svetlov report at bugs.python.org
Tue May 7 18:14:54 EDT 2019


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

The reason is: until connection_lost() is called the transport is in the active state. Destruction of closing-but-not-closed-yet trasport raises a ResourceWarning.


Plain TCP socket calls connection_lost() on the next loop iteration after  .abort() call.
SSL transport seems to do the same but in general it can require a few extra loop iterations.

Better to make `stream.abort()` async function to avoid problems in the future.
Otherwise, you always have to write

stream.abort()
await stream.wait_closed()

which I consider a bad API

----------

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


More information about the Python-bugs-list mailing list