gh-113538: Don't error in stream reader protocol callback when task is cancelled (#113690)

This commit is contained in:
Guido van Rossum 2024-01-04 12:20:21 -08:00 committed by GitHub
parent 1600d78e2d
commit 4681a5271a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View file

@ -246,6 +246,9 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
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({