summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2024-01-04 20:20:21 (GMT)
committerGitHub <noreply@github.com>2024-01-04 20:20:21 (GMT)
commit4681a5271a8598b46021cbc556ac8098ab8a1d81 (patch)
tree56b7bcaaf0ae3ce4ef3346ff1bb4c7d5728063f3 /Lib/asyncio/streams.py
parent1600d78e2d090319930c6538b496ffcca120a696 (diff)
downloadcpython-4681a5271a8598b46021cbc556ac8098ab8a1d81.zip
cpython-4681a5271a8598b46021cbc556ac8098ab8a1d81.tar.gz
cpython-4681a5271a8598b46021cbc556ac8098ab8a1d81.tar.bz2
gh-113538: Don't error in stream reader protocol callback when task is cancelled (#113690)
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r--Lib/asyncio/streams.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index ffb48b9..df58b7a 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -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({