-
-
Notifications
You must be signed in to change notification settings - Fork 365
Open
Description
This is what happens when you don't wrap your async context's exit handler in a shielded cancel scope:
… trick question. Nothing happens – the error gets dropped on the floor. Since this is a fairly common mistake (at least IME) I wonder whether we can do something about it. If not (which is what I suspect) we need to document this pitfall more loudly.
import trio
class bar:
async def __aenter__(self):
return self
async def __aexit__(self, *tb):
await trio.sleep(0)
async def foo():
with trio.open_cancel_scope() as s:
async with bar():
s.cancel()
raise RuntimeError("Duh")
trio.run(foo)
GalaxySnail