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.

classification
Title: Add stream.abort() async method
Type: Stage: resolved
Components: asyncio Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder: Merge StreamWriter and StreamReader into just asyncio.Stream
View: 36889
Assigned To: Nosy List: asvetlov, yselivanov
Priority: normal Keywords:

Created on 2019-05-07 20:10 by asvetlov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg341811 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-07 20:10
It should call underlying `transport.abort()`, then wait for closing event (`await self.wait_closed()`)
msg341813 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-07 20:15
If we're just calling socket.close(), then what's the point of waiting for connection_lost?  (I remember us discussing this, but I don't quite remember the details).

Usually .abort() is a synchronous method, which kind of signals that "i want to close this immediately and I don't care what happens to it".
msg341836 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-07 22:14
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
msg343680 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-27 20:01
Fixed by #36889
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 81021
2019-05-27 20:01:30asvetlovsetstatus: open -> closed
superseder: Merge StreamWriter and StreamReader into just asyncio.Stream
messages: + msg343680

resolution: fixed
stage: resolved
2019-05-07 22:14:54asvetlovsetmessages: + msg341836
2019-05-07 20:15:52yselivanovsetmessages: + msg341813
2019-05-07 20:10:06asvetlovcreate