This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author John Belmonte
Recipients David Hoyes, John Belmonte, jbelmonte, njs
Date 2021-07-12.00:56:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626051380.12.0.506442792275.issue44594@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-07-12 00:56:20John Belmontesetrecipients: + John Belmonte, jbelmonte, njs, David Hoyes
2021-07-12 00:56:20John Belmontesetmessageid: <1626051380.12.0.506442792275.issue44594@roundup.psfhosted.org>
2021-07-12 00:56:20John Belmontelinkissue44594 messages
2021-07-12 00:56:20John Belmontecreate