Message397271
demonstrating the difference for async case:
import contextlib
import trio
async def background():
assert False
async def main1():
async with trio.open_nursery() as nursery:
nursery.start_soon(background)
await trio.sleep_forever()
async def main2():
async with contextlib.AsyncExitStack() as stack:
nursery = await stack.enter_async_context(trio.open_nursery())
nursery.start_soon(background)
await trio.sleep_forever()
try:
trio.run(main1)
except BaseException as e:
print('main1, context:', e.__context__)
try:
trio.run(main2)
except BaseException as e:
print('main2, context:', e.__context__)
----
main1, context: None
main2, context: Cancelled |
|
Date |
User |
Action |
Args |
2021-07-12 00:56:20 | John Belmonte | set | recipients:
+ John Belmonte, jbelmonte, njs, David Hoyes |
2021-07-12 00:56:20 | John Belmonte | set | messageid: <1626051380.12.0.506442792275.issue44594@roundup.psfhosted.org> |
2021-07-12 00:56:20 | John Belmonte | link | issue44594 messages |
2021-07-12 00:56:20 | John Belmonte | create | |
|