Skip to content

Commit deb5a15

Browse files
committed
Catch cancellation as part of BaseException (python/cpython#13528)
* See also: https://bugs.python.org/issue32528 * This change makes actxmgr cancellation behaviors in Python 3.6/3.7/3.8 consistent.
1 parent 9efc66a commit deb5a15

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/aiotools/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def __aexit__(self, exc_type, exc_value, tb):
135135
return False
136136
# If this is a purely new exception, raise the new one.
137137
raise
138-
except BaseException as exc:
138+
except (BaseException, asyncio.CancelledError) as exc:
139139
if exc is not exc_value:
140140
raise
141141

src/aiotools/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ async def __aexit__(self, exc_type, exc_value, tb):
120120
if exc_new_value.__cause__ is exc_value:
121121
return False
122122
raise
123-
except BaseException as exc:
123+
except (BaseException, asyncio.CancelledError) as exc:
124124
if exc is not exc_value:
125125
raise
126126

0 commit comments

Comments
 (0)