forked from goodboy/tractor
Right, only worry about pdb lock when in debug mode
parent
a42ec1f571
commit
e4ed0fd2b3
|
@ -21,7 +21,7 @@ from trio_typing import TaskStatus
|
||||||
from .log import get_logger
|
from .log import get_logger
|
||||||
from . import _state
|
from . import _state
|
||||||
from ._discovery import get_root
|
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
|
from ._exceptions import is_multi_cancelled
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -525,7 +525,7 @@ post_mortem = partial(
|
||||||
|
|
||||||
async def _maybe_enter_pm(err):
|
async def _maybe_enter_pm(err):
|
||||||
if (
|
if (
|
||||||
_state.debug_mode()
|
debug_mode()
|
||||||
|
|
||||||
# NOTE: don't enter debug mode recursively after quitting pdb
|
# NOTE: don't enter debug mode recursively after quitting pdb
|
||||||
# Iow, don't re-enter the repl if the `quit` command was issued
|
# 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,
|
poll_delay: float = 0.1,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
if not _state.debug_mode():
|
if not debug_mode():
|
||||||
return
|
return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -30,6 +30,7 @@ from ._state import (
|
||||||
current_actor,
|
current_actor,
|
||||||
is_main_process,
|
is_main_process,
|
||||||
is_root_process,
|
is_root_process,
|
||||||
|
debug_mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .log import get_logger
|
from .log import get_logger
|
||||||
|
@ -242,8 +243,10 @@ async def new_proc(
|
||||||
subactor.uid)
|
subactor.uid)
|
||||||
except trio.Cancelled:
|
except trio.Cancelled:
|
||||||
cancel_during_spawn = True
|
cancel_during_spawn = True
|
||||||
|
|
||||||
# we may cancel before the child connects back in which
|
# we may cancel before the child connects back in which
|
||||||
# case avoid clobbering the pdb tty.
|
# case avoid clobbering the pdb tty.
|
||||||
|
if debug_mode():
|
||||||
with trio.CancelScope(shield=True):
|
with trio.CancelScope(shield=True):
|
||||||
# don't clobber an ongoing pdb
|
# don't clobber an ongoing pdb
|
||||||
if is_root_process():
|
if is_root_process():
|
||||||
|
@ -312,9 +315,8 @@ async def new_proc(
|
||||||
# don't clobber an ongoing pdb
|
# don't clobber an ongoing pdb
|
||||||
await maybe_wait_for_debugger()
|
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):
|
async with acquire_debug_lock(uid):
|
||||||
with trio.move_on_after(0.5):
|
with trio.move_on_after(0.5):
|
||||||
await proc.wait()
|
await proc.wait()
|
||||||
|
|
Loading…
Reference in New Issue