Tidy `spawn/` subpkg docstrings and imports
Drop unused `TYPE_CHECKING` imports (`Channel`, `_server`), remove commented-out `import os` in `_entry.py`, and use `get_runtime_vars()` accessor instead of bare `_runtime_vars` in `_trio.py`. Also, - freshen `__init__.py` layout docstring for the new per-backend submod structure - update `_spawn.py` + `_trio.py` module docstrings (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codesubint_spawner_backend
parent
e0b8f23cbc
commit
f75865fb2e
|
|
@ -17,29 +17,24 @@
|
||||||
'''
|
'''
|
||||||
Actor process spawning machinery using multiple backends.
|
Actor process spawning machinery using multiple backends.
|
||||||
|
|
||||||
Layout
|
- `._spawn`: cross-backend subactor-as-sub[proc|int] spawning
|
||||||
------
|
and supervision routines.
|
||||||
- `._spawn`: the "core" supervisor machinery — spawn-method
|
|
||||||
registry (`SpawnMethodKey`, `_methods`, `_spawn_method`,
|
|
||||||
`_ctx`, `try_set_start_method`), the `new_proc` dispatcher,
|
|
||||||
and the cross-backend helpers `exhaust_portal`,
|
|
||||||
`cancel_on_completion`, `hard_kill`, `soft_kill`,
|
|
||||||
`proc_waiter`.
|
|
||||||
|
|
||||||
Per-backend submodules (each exposes a single `*_proc()`
|
Per-backend submodules (each exposes a single `*_proc()`
|
||||||
coroutine registered in `_spawn._methods`):
|
coroutine registered in `_spawn._methods`):
|
||||||
|
|
||||||
- `._trio`: the `trio`-native subprocess backend (default,
|
- `._trio`: the `trio`-native subprocess backend (default,
|
||||||
all platforms), spawns via `trio.lowlevel.open_process()`.
|
all platforms), spawns via `trio.lowlevel.open_process()`.
|
||||||
- `._mp`: the stdlib `multiprocessing` backends —
|
|
||||||
`'mp_spawn'` and `'mp_forkserver'` variants — driven by
|
- `._mp`: the stdlib `multiprocessing` backend variants — driven by
|
||||||
the `mp.context` bound to `_spawn._ctx`.
|
the `mp.context` bound to `_spawn._ctx`:
|
||||||
|
* `'mp_spawn'`,
|
||||||
|
* `'mp_forkserver'`
|
||||||
|
|
||||||
Entry-point helpers live in `._entry`/`._mp_fixup_main`/
|
Entry-point helpers live in `._entry`/`._mp_fixup_main`/
|
||||||
`._forkserver_override`.
|
`._forkserver_override`.
|
||||||
|
|
||||||
NOTE: to avoid circular imports, this ``__init__`` does NOT
|
NOTE: to avoid circular imports, this ``__init__`` does NOT eagerly
|
||||||
eagerly import submodules. Use direct module paths like
|
import submodules.
|
||||||
``tractor.spawn._spawn`` or ``tractor.spawn._trio`` instead.
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ Sub-process entry points.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
# import os
|
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ from ._spawn import (
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from tractor.ipc import (
|
from tractor.ipc import (
|
||||||
_server,
|
_server,
|
||||||
Channel,
|
|
||||||
)
|
)
|
||||||
from tractor.runtime._supervise import ActorNursery
|
from tractor.runtime._supervise import ActorNursery
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Machinery for actor process spawning using multiple backends.
|
Top level routines & machinery for actor-as-process/subint spawning
|
||||||
|
over multiple backends.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -35,7 +36,6 @@ from trio import TaskStatus
|
||||||
|
|
||||||
from ..devx import debug
|
from ..devx import debug
|
||||||
from tractor.runtime._state import (
|
from tractor.runtime._state import (
|
||||||
debug_mode,
|
|
||||||
_runtime_vars,
|
_runtime_vars,
|
||||||
)
|
)
|
||||||
from tractor.log import get_logger
|
from tractor.log import get_logger
|
||||||
|
|
@ -47,7 +47,6 @@ from tractor.msg import types as msgtypes
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from tractor.ipc import (
|
from tractor.ipc import (
|
||||||
_server,
|
|
||||||
Channel,
|
Channel,
|
||||||
)
|
)
|
||||||
from tractor.runtime._supervise import ActorNursery
|
from tractor.runtime._supervise import ActorNursery
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,10 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
The `trio` subprocess spawning backend.
|
The `trio`-subprocess backend; the default for cross-platform.
|
||||||
|
|
||||||
Spawns sub-actors as fresh OS processes driven by
|
Spawns sub-actors as fresh OS processes driven by
|
||||||
`trio.lowlevel.open_process()` — our default, cross-platform
|
`trio.lowlevel.open_process()`.
|
||||||
spawn method.
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -40,7 +39,7 @@ from tractor.runtime._state import (
|
||||||
current_actor,
|
current_actor,
|
||||||
is_root_process,
|
is_root_process,
|
||||||
debug_mode,
|
debug_mode,
|
||||||
_runtime_vars,
|
get_runtime_vars,
|
||||||
)
|
)
|
||||||
from tractor.log import get_logger
|
from tractor.log import get_logger
|
||||||
from tractor.discovery._addr import UnwrappedAddress
|
from tractor.discovery._addr import UnwrappedAddress
|
||||||
|
|
@ -60,7 +59,6 @@ from ._spawn import (
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from tractor.ipc import (
|
from tractor.ipc import (
|
||||||
_server,
|
_server,
|
||||||
Channel,
|
|
||||||
)
|
)
|
||||||
from tractor.runtime._supervise import ActorNursery
|
from tractor.runtime._supervise import ActorNursery
|
||||||
|
|
||||||
|
|
@ -248,7 +246,7 @@ async def trio_proc(
|
||||||
await proc.wait()
|
await proc.wait()
|
||||||
|
|
||||||
await debug.maybe_wait_for_debugger(
|
await debug.maybe_wait_for_debugger(
|
||||||
child_in_debug=_runtime_vars.get(
|
child_in_debug=get_runtime_vars().get(
|
||||||
'_debug_mode', False
|
'_debug_mode', False
|
||||||
),
|
),
|
||||||
header_msg=(
|
header_msg=(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue