summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-01-04 20:39:52 (GMT)
committerGitHub <noreply@github.com>2024-01-04 20:39:52 (GMT)
commit456e2ecdd24f372bffd3083b9e4e51ca973f81f6 (patch)
tree0335fc376f6c98b0a56b35924e75162fe1d23707 /Lib/asyncio/streams.py
parentc828dbc196519f942418953aa9758e2df3a0bd9b (diff)
downloadcpython-456e2ecdd24f372bffd3083b9e4e51ca973f81f6.zip
cpython-456e2ecdd24f372bffd3083b9e4e51ca973f81f6.tar.gz
cpython-456e2ecdd24f372bffd3083b9e4e51ca973f81f6.tar.bz2
[3.11] gh-113538: Don't error in stream reader protocol callback when task is cancelled (GH-113690) (#113714)
(cherry picked from commit 4681a5271a8598b46021cbc556ac8098ab8a1d81) Co-authored-by: Guido van Rossum <guido@python.org>
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 23b6e4c..26ffc86 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({