forked from goodboy/tractor
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
parent
ce4d64ed2f
commit
9ce958cb4a
|
@ -43,6 +43,7 @@ from tractor._state import (
|
||||||
is_main_process,
|
is_main_process,
|
||||||
is_root_process,
|
is_root_process,
|
||||||
debug_mode,
|
debug_mode,
|
||||||
|
_runtime_vars,
|
||||||
)
|
)
|
||||||
from tractor.log import get_logger
|
from tractor.log import get_logger
|
||||||
from tractor._portal import Portal
|
from tractor._portal import Portal
|
||||||
|
@ -299,7 +300,6 @@ async def hard_kill(
|
||||||
|
|
||||||
|
|
||||||
async def soft_kill(
|
async def soft_kill(
|
||||||
|
|
||||||
proc: ProcessType,
|
proc: ProcessType,
|
||||||
wait_func: Callable[
|
wait_func: Callable[
|
||||||
[ProcessType],
|
[ProcessType],
|
||||||
|
@ -329,6 +329,18 @@ async def soft_kill(
|
||||||
await wait_func(proc)
|
await wait_func(proc)
|
||||||
|
|
||||||
except trio.Cancelled:
|
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
|
# if cancelled during a soft wait, cancel the child
|
||||||
# actor before entering the hard reap sequence
|
# actor before entering the hard reap sequence
|
||||||
# below. This means we try to do a graceful teardown
|
# below. This means we try to do a graceful teardown
|
||||||
|
|
Loading…
Reference in New Issue