mypy fixes

bug_in_debug
Tyler Goodlet 2020-10-13 11:03:55 -04:00
parent 1710b642a5
commit c375a2d028
4 changed files with 14 additions and 11 deletions

View File

@ -17,6 +17,7 @@ from ._discovery import get_arbiter, find_actor, wait_for_actor
from ._actor import Actor, _start_actor, Arbiter
from ._trionics import open_nursery
from ._state import current_actor
from . import _state
from ._exceptions import RemoteActorError, ModuleNotExposed
from ._debug import breakpoint, post_mortem
from . import msg
@ -24,6 +25,8 @@ from . import _spawn
__all__ = [
'breakpoint',
'post_mortem',
'current_actor',
'find_actor',
'get_arbiter',
@ -51,7 +54,7 @@ async def _main(
name: Optional[str] = None,
start_method: Optional[str] = None,
debug_mode: bool = False,
**kwargs: typing.Dict[str, typing.Any],
**kwargs,
) -> typing.Any:
"""Async entry point for ``tractor``.
"""

View File

@ -249,7 +249,7 @@ class Actor:
self._parent_chan: Optional[Channel] = None
self._forkserver_info: Optional[
Tuple[Any, Any, Any, Any, Any]] = None
self._actoruid2nursery: Dict[str, 'ActorNursery'] = {} # noqa
self._actoruid2nursery: Dict[str, 'ActorNursery'] = {} # type: ignore
async def wait_for_peer(
self, uid: Tuple[str, str]

View File

@ -5,7 +5,7 @@ import bdb
import sys
from functools import partial
from contextlib import asynccontextmanager
from typing import Awaitable, Tuple, Optional, Callable
from typing import Awaitable, Tuple, Optional, Callable, AsyncIterator
# import signal
from async_generator import aclosing
@ -22,9 +22,9 @@ try:
# wtf: only exported when installed in dev mode?
import pdbpp
except ImportError:
# pdbpp is installed in regular mode...
# pdbpp is installed in regular mode...it monkey patches stuff
import pdb
assert pdb.xpm, "pdbpp is not installed?"
assert pdb.xpm, "pdbpp is not installed?" # type: ignore
pdbpp = pdb
log = get_logger(__name__)
@ -45,7 +45,7 @@ _debug_lock = trio.StrictFIFOLock()
# XXX: set by the current task waiting on the root tty lock
# and must be cancelled if this actor is cancelled via message
# otherwise deadlocks with the parent actor may ensure
_debugger_request_cs: trio.CancelScope = None
_debugger_request_cs: Optional[trio.CancelScope] = None
class TractorConfig(pdbpp.DefaultConfig):
@ -117,7 +117,7 @@ class PdbwTeardown(pdbpp.Pdb):
@asynccontextmanager
async def _acquire_debug_lock(uid: Tuple[str, str]) -> None:
async def _acquire_debug_lock(uid: Tuple[str, str]) -> AsyncIterator[None]:
"""Acquire a actor local FIFO lock meant to mutex entry to a local
debugger entry point to avoid tty clobbering by multiple processes.
"""
@ -158,7 +158,7 @@ pdbpp.pdb.Pdb.sigint_handler = handler
async def _hijack_stdin_relay_to_child(
subactor_uid: Tuple[str, str]
) -> None:
) -> AsyncIterator[str]:
# TODO: when we get to true remote debugging
# this will deliver stdin data
log.warning(f"Actor {subactor_uid} is WAITING on stdin hijack lock")

View File

@ -1,14 +1,14 @@
"""
Per process state
"""
from typing import Optional
from typing import Optional, Dict, Any
from collections import Mapping
import multiprocessing as mp
import trio
_current_actor: Optional['Actor'] = None # type: ignore
_runtime_vars = {
_runtime_vars: Dict[str, Any] = {
'_debug_mode': False,
'_is_root': False,
'_root_mailbox': (None, None)
@ -54,7 +54,7 @@ def debug_mode() -> bool:
"""Bool determining if "debug mode" is on which enables
remote subactor pdb entry on crashes.
"""
return _runtime_vars['_debug_mode']
return bool(_runtime_vars['_debug_mode'])
def is_root_process() -> bool: