Update debug examples + harden `test_debugger`

Pass explicit `loglevel` to `spawn()` calls in
`test_debugger` tests — required for pexpect
pattern matching now that examples no longer
hard-code log levels.

Also,
- make `expect()` return the decoded `before` str.
- add `start_method` param + fork-backend timeout
  slack (+4s) in nested-error test.
- clean up debug examples: drop unused loglevels,
  rename `n` -> `an`, fix docstrings, add TODO
  comments for tpt parametrize via osenv.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
subint_forkserver_backend
Gud Boi 2026-05-01 00:13:22 -04:00
parent fc2e298a29
commit 9431a81d37
8 changed files with 49 additions and 26 deletions

View File

@ -27,12 +27,9 @@ async def main():
'''
async with tractor.open_nursery(
debug_mode=True,
loglevel='cancel',
# loglevel='devx',
) as n:
p0 = await n.start_actor('bp_forever', enable_modules=[__name__])
p1 = await n.start_actor('name_error', enable_modules=[__name__])
) as an:
p0 = await an.start_actor('bp_forever', enable_modules=[__name__])
p1 = await an.start_actor('name_error', enable_modules=[__name__])
# retreive results
async with p0.open_stream_from(breakpoint_forever) as stream:

View File

@ -67,7 +67,7 @@ async def main():
"""
async with tractor.open_nursery(
debug_mode=True,
# loglevel='cancel',
loglevel='pdb',
) as n:
# spawn both actors

View File

@ -39,8 +39,8 @@ async def main():
'''
async with tractor.open_nursery(
debug_mode=True,
loglevel='devx',
enable_transports=['uds'],
enable_transports=['uds'], # TODO, apss this via osenv?
loglevel='devx', # XXX, required for test!
) as n:
# spawn both actors

View File

@ -1,4 +1,3 @@
import trio
import tractor
@ -9,16 +8,22 @@ async def key_error():
async def main():
"""Root dies
'''
Root is fail-after-cancelled while blocking and child RPC fails
simultaneously.
"""
'''
async with tractor.open_nursery(
debug_mode=True,
loglevel='debug'
# loglevel='debug' # ?XXX required?
) as n:
# spawn both actors
portal = await n.run_in_actor(key_error)
print(
f'Child is up @ {portal.chan.aid.reprol()}'
)
# XXX: originally a bug caused by this is where root would enter
# the debugger and clobber the tty used by the repl even though

View File

@ -36,6 +36,11 @@ async def just_bp(
async def main():
# !TODO, parametrize the --tpt-proto={key} with osenv vars just
# like we do for loglevel/spawn-backend!
# - [ ] run on both tpts for all such debugger tests?
# - [ ] special skip for macos!
#
if platform.system() != 'Darwin':
tpt = 'uds'
else:

View File

@ -9,7 +9,6 @@ async def name_error():
async def main():
async with tractor.open_nursery(
debug_mode=True,
# loglevel='transport',
) as an:
# TODO: ideally the REPL arrives at this frame in the parent,

View File

@ -269,13 +269,10 @@ def ctlc(
def expect(
child,
# normally a `pdb` prompt by default
patt: str,
patt: str, # often a `pdbp`-prompt
**kwargs,
) -> None:
) -> str:
'''
Expect wrapper that prints last seen console
data before failing.
@ -286,6 +283,8 @@ def expect(
patt,
**kwargs,
)
before = str(child.before.decode())
return before
except TIMEOUT:
before = str(child.before.decode())
print(before)

View File

@ -765,6 +765,7 @@ def test_multi_subactors_root_errors(
def test_multi_nested_subactors_error_through_nurseries(
ci_env: bool,
spawn: PexpectSpawner,
start_method: str,
# TODO: address debugger issue for nested tree:
# https://github.com/goodboy/tractor/issues/320
@ -781,16 +782,16 @@ def test_multi_nested_subactors_error_through_nurseries(
# A test (below) has now been added to explicitly verify this is
# fixed.
child = spawn('multi_nested_subactors_error_up_through_nurseries')
# timed_out_early: bool = False
child = spawn(
'multi_nested_subactors_error_up_through_nurseries',
loglevel='pdb',
)
for (
i,
send_char,
) in enumerate(itertools.cycle(['c', 'q'])):
timeout: float = -1
timeout: float = child.timeout
if (
_non_linux
and
@ -803,6 +804,15 @@ def test_multi_nested_subactors_error_through_nurseries(
elif i == 0:
timeout = 5
# XXX forking backends may take longer due to
# determinstic IPC cancellation.
if (
start_method in [
'main_thread_forkserver',
]
):
timeout += 4
try:
child.expect(
PROMPT,
@ -1187,7 +1197,11 @@ def test_ctxep_pauses_n_maybe_ipc_breaks(
mashed and zombie reaper kills sub with no hangs.
'''
child = spawn('subactor_bp_in_ctx')
child = spawn(
'subactor_bp_in_ctx',
loglevel='devx'
# ^XXX REQUIRED for below patt matching!
)
child.expect(PROMPT)
# 3 iters for the `gen()` pause-points
@ -1277,7 +1291,11 @@ def test_crash_handling_within_cancelled_root_actor(
call.
'''
child = spawn('root_self_cancelled_w_error')
child = spawn(
'root_self_cancelled_w_error',
loglevel='cancel',
# ^XXX REQUIRED for below patt matching!
)
child.expect(PROMPT)
assert_before(