forked from goodboy/tractor
1
0
Fork 0

Add debug check-n-wait inside `._spawn.soft_kill()`

And IFF the `await wait_func(proc)` is cancelled such that we avoid
clobbering some subactor that might be REPL-ing even though its parent
actor is in the midst of (gracefully) cancelling it.
runtime_to_msgspec
Tyler Goodlet 2024-05-22 15:21:01 -04:00
parent ce4d64ed2f
commit 9ce958cb4a
1 changed files with 13 additions and 1 deletions

View File

@ -43,6 +43,7 @@ from tractor._state import (
is_main_process,
is_root_process,
debug_mode,
_runtime_vars,
)
from tractor.log import get_logger
from tractor._portal import Portal
@ -299,7 +300,6 @@ async def hard_kill(
async def soft_kill(
proc: ProcessType,
wait_func: Callable[
[ProcessType],
@ -329,6 +329,18 @@ async def soft_kill(
await wait_func(proc)
except trio.Cancelled:
with trio.CancelScope(shield=True):
await maybe_wait_for_debugger(
child_in_debug=_runtime_vars.get(
'_debug_mode', False
),
header_msg=(
'Delaying `soft_kill()` subproc reaper while debugger locked..\n'
),
# TODO: need a diff value then default?
# poll_steps=9999999,
)
# if cancelled during a soft wait, cancel the child
# actor before entering the hard reap sequence
# below. This means we try to do a graceful teardown