Skip to content

Instantly share code, notes, and snippets.

@agronholm
Created September 29, 2019 21:17
Show Gist options
  • Save agronholm/8b32bba4c83a25c7f981f2ea1eec82bb to your computer and use it in GitHub Desktop.
Save agronholm/8b32bba4c83a25c7f981f2ea1eec82bb to your computer and use it in GitHub Desktop.
Test handling of an exception when the nursery has no active host task
import trio
async def error_after(delay):
await trio.sleep(delay)
raise Exception('foo')
async def somegenerator():
try:
async with trio.open_nursery() as nursery:
nursery.start_soon(error_after, 1)
yield
except BaseException as exc:
print(exc)
async def main():
async for _ in gen:
await trio.sleep(2)
gen = somegenerator()
trio.run(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment