Skip to content

Commit

Permalink
Don't crash in stream reader protocol callback when task is cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Jan 3, 2024
1 parent fff1e8a commit 8eb5048
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lib/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ def connection_made(self, transport):
self._stream_writer)
if coroutines.iscoroutine(res):
def callback(task):
if task.cancelled():
transport.close()
return
exc = task.exception()
if exc is not None:
self._loop.call_exception_handler({
Expand Down

0 comments on commit 8eb5048

Please sign in to comment.