Strict egs everywhere: drop use of strict_exception_groups=False throughout!#390
Merged
Strict egs everywhere: drop use of strict_exception_groups=False throughout!#390
strict_exception_groups=False throughout!#390Conversation
b32121f to
0cbf02b
Compare
That is just throughout the core library, not the tests yet. Again, we simply change over to using our (nearly equivalent?) `.trionics.collapse_eg()` in place of the already deprecated `strict_exception_groups=False` flag in the following internals, - the conc-fan-out tn use in `._discovery.find_actor()`. - `._portal.open_portal()`'s internal tn used to spawn a bg rpc-msg-loop task. - the daemon and "run-in-actor" layered tn pair allocated in `._supervise._open_and_supervise_one_cancels_all_nursery()`. The remaining loose-eg usage in `._root` and `._runtime` seem to be necessary to keep the test suite green?? For the moment these are left out.
Since the `bdb` module was added to the namespace lookup set in `._exceptions.get_err_type()` we can now relay a RAE-boxed `bdb.BdbQuit`.
Seems to cause the following test suites to fail however.. - 'test_advanced_faults.py::test_ipc_channel_break_during_stream' - 'test_advanced_faults.py::test_ipc_channel_break_during_stream' - 'test_clustering.py::test_empty_mngrs_input_raises' Also tweak some ctxc request logging content.
Seems to add one more cancellation suite failure as well as now cause the discovery test to error instead of fail?
I dunno what exactly I was thinking but we definitely don't want to **ever** raise from the original exc-group, instead always raise from any original `.__cause__` to be consistent with the embedded src-error's context. Also, adjust `maybe_collapse_eg()` to return `False` in the non-single `.exceptions` case, again don't know what I was trying to do but this simplifies caller logic and the prior return-semantic had no real value.. This fixes some final usage in the runtime (namely top level nursery usage in `._root`/`._runtime`) which was previously causing test suite failures prior to this fix.
Replacing yet another loose-eg-flag. Also toss in a todo to maybe use the unmasker around the `open_root_actor()` body.
Since it turns out the semantics are basically inverse of normal `except` (particularly for re-raising) which is hard to get right, and bc it's a lot easier to just delegate to what `trio` already has behind the `strict_exception_groups=False` setting, Bp I added a rant here which will get removed shortly likely, but i think going forward recommending against use of `except*` is prudent for anything low level enough in the runtime (like trying to filter begs). Dirty deats, - copy `trio._core._run.collapse_exception_group()` to here with only a slight mod to remove the notes check and tb concatting for the collapse case. - rename `maybe_collapse_eg()` - > `get_collapsed_eg()` and delegate it directly to the former `trio` fn; return `None` when it returns the same beg without collapse. - simplify our own `collapse_eg()` to either raise the collapsed `exc` or original `beg`.
It was originally this way; I forgot to flip it back when discarding the `except*` handler impl.. Specially handle the `exc.__cause__` case where we raise from any detected underlying cause and OW `from None` to suppress the eg's tb.
Seems that the way the actor-nursery interacts with the `.trionics.gather_contexts()` API on cancellation makes our `.trionics.collapse_eg()` not work as intended? I need to dig into how `ActorNursery.cancel()` and `.__aexit__()` might be causing this discrepancy.. Consider this a commit-of-my-index type save for rn.
Namely `test_empty_mngrs_input_raises()` was failing due to lazy-iterator use as input to `mngrs` which i guess i added support for a while back (by it doing a `list(mngrs)` internally)? So just change it to `gather_contexts(mngrs=())` and also tweak the `trio.fail_after(3)` since it appears that the prior 1sec was causing too-fast-of-a-cancellation (before the cluster fully spawned) and thus the expected `ValueError` never to show.. Also, mask the `tractor.trionics.collapse_eg()` usage (again?) in `open_actor_cluster()` since it seems unnecessary.
Was failing due to the `.fail_after()` timeout being *too short* and somehow the new interplay of that with strict-exception groups resulting in the `TooSlowError` never raising but instead an eg with the embedded `AssertionError`?? I still don't really get it honestly.. I've written up lengthy notes around the different `delay` settings that can be used to see the diff outcomes, the failing case being the one i still don't really grok and think is justification for `trio` to bubble inner `Cancelled`s differently possibly? For now i've included the original failing case as an `xfail` parametrization for now which will hopefully drive a follow lowlevel `trio` test in `test_trioisms`!
As mentioned in prior testing commit, it can cause the worst kind of hangs, the SIGINT ignoring kind.. Pretty sure there was never any reason outside some esoteric multi-actor debugging case, and pretty sure that already was solved?
048eb4a to
e3a542f
Compare
goodboy
commented
Aug 18, 2025
| await n.start(spawn_and_sleep_forever) | ||
| async with ( | ||
|
|
||
| # XXX ?TODO? why no work!? |
Owner
Author
There was a problem hiding this comment.
This one needs more investigation but likely interplays with stuff we'll resolve in #391?
4 tasks
guilledk
approved these changes
Aug 18, 2025
5188d2a to
88c1c08
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Making us future-proofed for any
triorelease which finally removesthe flag and thus all "loose support" throughout the runtime core.
Flag removal is made possible by a new
tractor.trionics.collapse_eg()stackable@acmwhich can be layedonto
trio.Nurseryblocks and get effectively the same behaviour(minus warnings and some tb mangling) as
strict_exeception_groups=Falseby delegating verbatim totrio'sinternal
trio._core._run.collapse_exception_group()except we,remove the
NONSTRICT_EXCEPTIONGROUP_NOTEdeprecation-noteguard-check; we know we want an explicit collapse when used.
mask out the traceback rewriting in collapse case, i don't think it
really matters for us?
Note that the
.collapse_eg()soln was already introduced prior (inhttps://pikers.dev/goodboy/tractor/pulls/18) but wasn't yet used nor
was it implemented correctly until this patch..
Change-set lower level deats,
re-implementing
collapse_eg()to not useexcept*(which inimho is a massive footgun of syntax they prolly should have never
added, see my original rant-comment in 048b154) and instead catch
BaseExceptionGroupand passing it directly to thetriocollapser.
wrap our
collapse_exception_group()delegation call ina
maybe_collapse_eg()which predicates whether a single non-eg isfound.
add a
'( ^^^ this exc was collapsed from a group ^^^ )'note toany collapsed and re-raised exceptions.
since we do ^, also strip out any
""during the handling of <beg> the following.."beg traceback content by always raisinga collapsed exec from its orig
.__cause__if possible orfrom None.adding a bit of tooling to our
.collapse_eg()including,__tracebackhide__ = hid_tba new
bp: boolflag which only breaks when a beg with >1sub-exceptions is detected, which is obviously handy to
introspect (the source of) unexpected egs.
Updates to various test suites to match,
cluster API suites needed some tweaks that ended up having nothing
to do with actual strict-eg-tns but are included here.
d2ac9ec a cancellation test needed a longer timeout in order to
avoid the expected assert-error getting eg-embedded?
pytest.xfail()trio.fail_after()'scancelling of the parent scope
0ffcea1 adjusts a
test_root_infect_asyncio.pysuite to expectnon-eg/collapsed-exc raises.
Misc core tweaks,
ipc_server.wait_for_no_more_peers()which was causing hangs insome
trionicsrelated tests; the shield doesn't seem to benecessary in any case..
In follow up..
the test so
i've left it as a todo for A refined
trio.Cancelled-unmasking helper #391.