Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/anyio/_backends/_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,20 @@ def is_anyio_cancellation(exc: CancelledError) -> bool:
# Sometimes third party frameworks catch a CancelledError and raise a new one, so as
# a workaround we have to look at the previous ones in __context__ too for a
# matching cancel message
current = exc
while True:
args = current.args
if (
exc.args
and isinstance(exc.args[0], str)
and exc.args[0].startswith("Cancelled via cancel scope ")
args
and isinstance(args[0], str)
and args[0].startswith("Cancelled via cancel scope ")
):
return True

if isinstance(exc.__context__, CancelledError):
exc = exc.__context__
continue

return False
context = current.__context__
if not isinstance(context, CancelledError):
return False
current = context


class CancelScope(BaseCancelScope):
Expand Down