Drop `xfail` from `test_moc_reentry_during_teardown`

The per-`ctx_key` locking fix in f086222d intended to resolve the
teardown race reproduced by the new test suite, so the test SHOULD now
pass. TLDR, it doesn't Bp

Also add `collapse_eg()` to the test's ctx-manager stack so that when
run with `pytest <...> --tpdb` we'll actually `pdb`-REPL the RTE when it
hits (previously an assert-error).

(this commit-msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
maybe_open_ctx_locking
Gud Boi 2026-04-06 18:29:07 -04:00
parent f086222d74
commit 03c42e1333
1 changed files with 13 additions and 11 deletions

View File

@ -12,6 +12,7 @@ import trio
import tractor
from tractor.trionics import (
maybe_open_context,
collapse_eg,
)
from tractor.log import (
get_console_log,
@ -539,17 +540,17 @@ def test_per_ctx_key_resource_lifecycle(
trio.run(main)
@pytest.mark.xfail(
reason=(
'Demonstrates the `_Cache.run_ctx` teardown race: '
'a re-entering task hits '
'`assert not resources.get(ctx_key)` because '
'`values` was popped but `resources` was not yet '
'(acm `__aexit__` checkpoint in between). '
'Fixed by per-`ctx_key` locking in 9e49eddd.'
),
raises=AssertionError,
)
# @pytest.mark.xfail(
# reason=(
# 'Demonstrates the `_Cache.run_ctx` teardown race: '
# 'a re-entering task hits '
# '`assert not resources.get(ctx_key)` because '
# '`values` was popped but `resources` was not yet '
# '(acm `__aexit__` checkpoint in between). '
# 'Fixed by per-`ctx_key` locking in 9e49eddd.'
# ),
# raises=AssertionError,
# )
def test_moc_reentry_during_teardown(
debug_mode: bool,
loglevel: str,
@ -621,6 +622,7 @@ def test_moc_reentry_during_teardown(
debug_mode=debug_mode,
loglevel=loglevel,
),
collapse_eg(),
trio.open_nursery() as tn,
):
tn.start_soon(use_and_exit)