Created
September 29, 2019 21:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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