You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules.rst
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,16 +85,16 @@ _`ASYNC120` : await-in-except
85
85
If this checkpoint is cancelled, the current active exception will be replaced by the ``Cancelled`` exception, and cannot be reraised later.
86
86
This will not trigger when :ref:`ASYNC102 <ASYNC102>` does, and if you don't care about losing non-cancelled exceptions you could disable this rule.
87
87
This is currently not able to detect asyncio shields.
88
-
88
+
89
89
To handle this correctly, use a shielded cancel scope with a timeout::
90
-
90
+
91
91
try:
92
92
await process()
93
93
except Exception:
94
94
with trio.fail_after(seconds, shield=True):
95
95
await cleanup()
96
96
raise
97
-
97
+
98
98
The shield prevents cancellation from replacing the current exception, while the timeout ensures cleanup can't block indefinitely. Use :func:`trio.move_on_after` if you want to suppress timeout errors rather than raise them.
0 commit comments