forked from goodboy/tractor
1
0
Fork 0

Right, only worry about pdb lock when in debug mode

immediate_remote_cancels
Tyler Goodlet 2021-10-15 09:29:25 -04:00
parent a42ec1f571
commit e4ed0fd2b3
2 changed files with 17 additions and 15 deletions

View File

@ -21,7 +21,7 @@ from trio_typing import TaskStatus
from .log import get_logger
from . import _state
from ._discovery import get_root
from ._state import is_root_process
from ._state import is_root_process, debug_mode
from ._exceptions import is_multi_cancelled
try:
@ -525,7 +525,7 @@ post_mortem = partial(
async def _maybe_enter_pm(err):
if (
_state.debug_mode()
debug_mode()
# NOTE: don't enter debug mode recursively after quitting pdb
# Iow, don't re-enter the repl if the `quit` command was issued
@ -572,7 +572,7 @@ async def maybe_wait_for_debugger(
poll_delay: float = 0.1,
) -> None:
if not _state.debug_mode():
if not debug_mode():
return
if (

View File

@ -30,6 +30,7 @@ from ._state import (
current_actor,
is_main_process,
is_root_process,
debug_mode,
)
from .log import get_logger
@ -242,17 +243,19 @@ async def new_proc(
subactor.uid)
except trio.Cancelled:
cancel_during_spawn = True
# we may cancel before the child connects back in which
# case avoid clobbering the pdb tty.
with trio.CancelScope(shield=True):
# don't clobber an ongoing pdb
if is_root_process():
await maybe_wait_for_debugger()
else:
async with acquire_debug_lock(uid):
# soft wait on the proc to terminate
with trio.move_on_after(0.5):
await proc.wait()
if debug_mode():
with trio.CancelScope(shield=True):
# don't clobber an ongoing pdb
if is_root_process():
await maybe_wait_for_debugger()
else:
async with acquire_debug_lock(uid):
# soft wait on the proc to terminate
with trio.move_on_after(0.5):
await proc.wait()
raise
portal = Portal(chan)
@ -312,9 +315,8 @@ async def new_proc(
# don't clobber an ongoing pdb
await maybe_wait_for_debugger()
if cancel_during_spawn:
# Try again to avoid TTY clobbering.
# Try again to avoid TTY clobbering.
if cancel_during_spawn and debug_mode():
async with acquire_debug_lock(uid):
with trio.move_on_after(0.5):
await proc.wait()