Closed
Description
Currently, exceptions raised from a nursery.start()
'ed function will be wrapped in extra ExceptionGroup
(aka MultiError
), iff it's raised before task_status.started()
is called.
I think that for consistency, we should pull such exceptions (which might themselves be ExceptionGroup
s) out of the group added by the starter-nursery.
import trio
async def startable_fn_which_doesnt_contain_a_nursery(task_status):
if ...:
print("Something went wrong")
raise RuntimeError # this might be wrapped in an ExceptionGroup
task_status.started()
raise ValueError # ...but this will never be wrapped!
async def main():
async with trio.open_nursery() as nursery:
try:
# Uh-oh! With strict_exception_groups=True, the hidden inner nursery
# in `nursery.start` wraps our RuntimeError in an ExceptionGroup :-/
await nursery.start(startable_fn_which_doesnt_contain_a_nursery)
except RuntimeError:
print("No worries, we'll try something else.")
if __name__ == "__main__":
trio.run(main, strict_exception_groups=False) # passes
print("\n==============================================================\n")
trio.run(main, strict_exception_groups=True) # fails!
Metadata
Metadata
Assignees
Labels
No labels