From e0dfed82744fdbfd8781aba0934e403210af9415 Mon Sep 17 00:00:00 2001 From: AshwinDeshpandeBG Date: Thu, 28 Aug 2025 11:57:13 -0400 Subject: [PATCH 1/2] initial --- tornado/gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado/gen.py b/tornado/gen.py index 7bfbaf012c..2baab3ff02 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -221,7 +221,7 @@ def wrapper(*args, **kwargs): result = ctx_run(func, *args, **kwargs) except (Return, StopIteration) as e: result = _value_from_stopiteration(e) - except Exception: + except (Exception, asyncio.CancelledError): future_set_exc_info(future, sys.exc_info()) try: return future From e2e836a141165af30de041254f47b0674c4f23fe Mon Sep 17 00:00:00 2001 From: AshwinDeshpandeBG Date: Tue, 2 Sep 2025 13:21:22 -0400 Subject: [PATCH 2/2] catch CancelledError in Generator section --- tornado/gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado/gen.py b/tornado/gen.py index 2baab3ff02..313740503f 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -241,7 +241,7 @@ def wrapper(*args, **kwargs): future_set_result_unless_cancelled( future, _value_from_stopiteration(e) ) - except Exception: + except (Exception, asyncio.CancelledError): future_set_exc_info(future, sys.exc_info()) else: # Provide strong references to Runner objects as long