From 6c46882545c4c977fe4d78fdb86b7ae37254ba4c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 13 Jun 2025 22:06:55 -0400 Subject: [PATCH] Add some tooling params to `collapse_eg()` --- tractor/trionics/_beg.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tractor/trionics/_beg.py b/tractor/trionics/_beg.py index ad10f3bf..2407fca7 100644 --- a/tractor/trionics/_beg.py +++ b/tractor/trionics/_beg.py @@ -44,7 +44,10 @@ def maybe_collapse_eg( @acm -async def collapse_eg(): +async def collapse_eg( + hide_tb: bool = True, + raise_from_src: bool = False, +): ''' If `BaseExceptionGroup` raised in the body scope is "collapse-able" (in the same way that @@ -52,13 +55,15 @@ async def collapse_eg(): only raise the lone emedded non-eg in in place. ''' + __tracebackhide__: bool = hide_tb try: yield except* BaseException as beg: if ( exc := maybe_collapse_eg(beg) ) is not beg: - raise exc + from_exc = beg if raise_from_src else None + raise exc from from_exc raise beg