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-codesubint_forkserver_backend
parent
fc2e298a29
commit
9431a81d37
|
|
@ -27,12 +27,9 @@ async def main():
|
||||||
'''
|
'''
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
loglevel='cancel',
|
) as an:
|
||||||
# loglevel='devx',
|
p0 = await an.start_actor('bp_forever', enable_modules=[__name__])
|
||||||
) as n:
|
p1 = await an.start_actor('name_error', enable_modules=[__name__])
|
||||||
|
|
||||||
p0 = await n.start_actor('bp_forever', enable_modules=[__name__])
|
|
||||||
p1 = await n.start_actor('name_error', enable_modules=[__name__])
|
|
||||||
|
|
||||||
# retreive results
|
# retreive results
|
||||||
async with p0.open_stream_from(breakpoint_forever) as stream:
|
async with p0.open_stream_from(breakpoint_forever) as stream:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ async def main():
|
||||||
"""
|
"""
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
# loglevel='cancel',
|
loglevel='pdb',
|
||||||
) as n:
|
) as n:
|
||||||
|
|
||||||
# spawn both actors
|
# spawn both actors
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ async def main():
|
||||||
'''
|
'''
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
loglevel='devx',
|
enable_transports=['uds'], # TODO, apss this via osenv?
|
||||||
enable_transports=['uds'],
|
loglevel='devx', # XXX, required for test!
|
||||||
) as n:
|
) as n:
|
||||||
|
|
||||||
# spawn both actors
|
# spawn both actors
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
|
|
@ -9,16 +8,22 @@ async def key_error():
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
"""Root dies
|
'''
|
||||||
|
Root is fail-after-cancelled while blocking and child RPC fails
|
||||||
|
simultaneously.
|
||||||
|
|
||||||
"""
|
'''
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
loglevel='debug'
|
# loglevel='debug' # ?XXX required?
|
||||||
) as n:
|
) as n:
|
||||||
|
|
||||||
# spawn both actors
|
# spawn both actors
|
||||||
portal = await n.run_in_actor(key_error)
|
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
|
# XXX: originally a bug caused by this is where root would enter
|
||||||
# the debugger and clobber the tty used by the repl even though
|
# the debugger and clobber the tty used by the repl even though
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ async def just_bp(
|
||||||
|
|
||||||
async def main():
|
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':
|
if platform.system() != 'Darwin':
|
||||||
tpt = 'uds'
|
tpt = 'uds'
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ async def name_error():
|
||||||
async def main():
|
async def main():
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
debug_mode=True,
|
debug_mode=True,
|
||||||
# loglevel='transport',
|
|
||||||
) as an:
|
) as an:
|
||||||
|
|
||||||
# TODO: ideally the REPL arrives at this frame in the parent,
|
# TODO: ideally the REPL arrives at this frame in the parent,
|
||||||
|
|
|
||||||
|
|
@ -269,13 +269,10 @@ def ctlc(
|
||||||
|
|
||||||
def expect(
|
def expect(
|
||||||
child,
|
child,
|
||||||
|
patt: str, # often a `pdbp`-prompt
|
||||||
# normally a `pdb` prompt by default
|
|
||||||
patt: str,
|
|
||||||
|
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
||||||
) -> None:
|
) -> str:
|
||||||
'''
|
'''
|
||||||
Expect wrapper that prints last seen console
|
Expect wrapper that prints last seen console
|
||||||
data before failing.
|
data before failing.
|
||||||
|
|
@ -286,6 +283,8 @@ def expect(
|
||||||
patt,
|
patt,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
before = str(child.before.decode())
|
||||||
|
return before
|
||||||
except TIMEOUT:
|
except TIMEOUT:
|
||||||
before = str(child.before.decode())
|
before = str(child.before.decode())
|
||||||
print(before)
|
print(before)
|
||||||
|
|
|
||||||
|
|
@ -765,6 +765,7 @@ def test_multi_subactors_root_errors(
|
||||||
def test_multi_nested_subactors_error_through_nurseries(
|
def test_multi_nested_subactors_error_through_nurseries(
|
||||||
ci_env: bool,
|
ci_env: bool,
|
||||||
spawn: PexpectSpawner,
|
spawn: PexpectSpawner,
|
||||||
|
start_method: str,
|
||||||
|
|
||||||
# TODO: address debugger issue for nested tree:
|
# TODO: address debugger issue for nested tree:
|
||||||
# https://github.com/goodboy/tractor/issues/320
|
# 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
|
# A test (below) has now been added to explicitly verify this is
|
||||||
# fixed.
|
# fixed.
|
||||||
|
|
||||||
child = spawn('multi_nested_subactors_error_up_through_nurseries')
|
child = spawn(
|
||||||
|
'multi_nested_subactors_error_up_through_nurseries',
|
||||||
# timed_out_early: bool = False
|
loglevel='pdb',
|
||||||
|
)
|
||||||
for (
|
for (
|
||||||
i,
|
i,
|
||||||
send_char,
|
send_char,
|
||||||
) in enumerate(itertools.cycle(['c', 'q'])):
|
) in enumerate(itertools.cycle(['c', 'q'])):
|
||||||
|
|
||||||
timeout: float = -1
|
timeout: float = child.timeout
|
||||||
if (
|
if (
|
||||||
_non_linux
|
_non_linux
|
||||||
and
|
and
|
||||||
|
|
@ -803,6 +804,15 @@ def test_multi_nested_subactors_error_through_nurseries(
|
||||||
elif i == 0:
|
elif i == 0:
|
||||||
timeout = 5
|
timeout = 5
|
||||||
|
|
||||||
|
# XXX forking backends may take longer due to
|
||||||
|
# determinstic IPC cancellation.
|
||||||
|
if (
|
||||||
|
start_method in [
|
||||||
|
'main_thread_forkserver',
|
||||||
|
]
|
||||||
|
):
|
||||||
|
timeout += 4
|
||||||
|
|
||||||
try:
|
try:
|
||||||
child.expect(
|
child.expect(
|
||||||
PROMPT,
|
PROMPT,
|
||||||
|
|
@ -1187,7 +1197,11 @@ def test_ctxep_pauses_n_maybe_ipc_breaks(
|
||||||
mashed and zombie reaper kills sub with no hangs.
|
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)
|
child.expect(PROMPT)
|
||||||
|
|
||||||
# 3 iters for the `gen()` pause-points
|
# 3 iters for the `gen()` pause-points
|
||||||
|
|
@ -1277,7 +1291,11 @@ def test_crash_handling_within_cancelled_root_actor(
|
||||||
call.
|
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)
|
child.expect(PROMPT)
|
||||||
|
|
||||||
assert_before(
|
assert_before(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue