Skip to content

Commit f75865f

Browse files
committed
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-code
1 parent e0b8f23 commit f75865f

5 files changed

Lines changed: 15 additions & 25 deletions

File tree

tractor/spawn/__init__.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,24 @@
1717
'''
1818
Actor process spawning machinery using multiple backends.
1919
20-
Layout
21-
------
22-
- `._spawn`: the "core" supervisor machinery — spawn-method
23-
registry (`SpawnMethodKey`, `_methods`, `_spawn_method`,
24-
`_ctx`, `try_set_start_method`), the `new_proc` dispatcher,
25-
and the cross-backend helpers `exhaust_portal`,
26-
`cancel_on_completion`, `hard_kill`, `soft_kill`,
27-
`proc_waiter`.
20+
- `._spawn`: cross-backend subactor-as-sub[proc|int] spawning
21+
and supervision routines.
2822
2923
Per-backend submodules (each exposes a single `*_proc()`
3024
coroutine registered in `_spawn._methods`):
3125
3226
- `._trio`: the `trio`-native subprocess backend (default,
3327
all platforms), spawns via `trio.lowlevel.open_process()`.
34-
- `._mp`: the stdlib `multiprocessing` backends —
35-
`'mp_spawn'` and `'mp_forkserver'` variants — driven by
36-
the `mp.context` bound to `_spawn._ctx`.
28+
29+
- `._mp`: the stdlib `multiprocessing` backend variants — driven by
30+
the `mp.context` bound to `_spawn._ctx`:
31+
* `'mp_spawn'`,
32+
* `'mp_forkserver'`
3733
3834
Entry-point helpers live in `._entry`/`._mp_fixup_main`/
3935
`._forkserver_override`.
4036
41-
NOTE: to avoid circular imports, this ``__init__`` does NOT
42-
eagerly import submodules. Use direct module paths like
43-
``tractor.spawn._spawn`` or ``tractor.spawn._trio`` instead.
37+
NOTE: to avoid circular imports, this ``__init__`` does NOT eagerly
38+
import submodules.
4439
4540
'''

tractor/spawn/_entry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from __future__ import annotations
2222
from functools import partial
2323
import multiprocessing as mp
24-
# import os
2524
from typing import (
2625
Any,
2726
TYPE_CHECKING,

tractor/spawn/_mp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
if TYPE_CHECKING:
5858
from tractor.ipc import (
5959
_server,
60-
Channel,
6160
)
6261
from tractor.runtime._supervise import ActorNursery
6362

tractor/spawn/_spawn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
"""
18-
Machinery for actor process spawning using multiple backends.
18+
Top level routines & machinery for actor-as-process/subint spawning
19+
over multiple backends.
1920
2021
"""
2122
from __future__ import annotations
@@ -35,7 +36,6 @@
3536

3637
from ..devx import debug
3738
from tractor.runtime._state import (
38-
debug_mode,
3939
_runtime_vars,
4040
)
4141
from tractor.log import get_logger
@@ -47,7 +47,6 @@
4747

4848
if TYPE_CHECKING:
4949
from tractor.ipc import (
50-
_server,
5150
Channel,
5251
)
5352
from tractor.runtime._supervise import ActorNursery

tractor/spawn/_trio.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
'''
18-
The `trio` subprocess spawning backend.
18+
The `trio`-subprocess backend; the default for cross-platform.
1919
2020
Spawns sub-actors as fresh OS processes driven by
21-
`trio.lowlevel.open_process()` — our default, cross-platform
22-
spawn method.
21+
`trio.lowlevel.open_process()`.
2322
2423
'''
2524
from __future__ import annotations
@@ -40,7 +39,7 @@
4039
current_actor,
4140
is_root_process,
4241
debug_mode,
43-
_runtime_vars,
42+
get_runtime_vars,
4443
)
4544
from tractor.log import get_logger
4645
from tractor.discovery._addr import UnwrappedAddress
@@ -60,7 +59,6 @@
6059
if TYPE_CHECKING:
6160
from tractor.ipc import (
6261
_server,
63-
Channel,
6462
)
6563
from tractor.runtime._supervise import ActorNursery
6664

@@ -248,7 +246,7 @@ async def trio_proc(
248246
await proc.wait()
249247

250248
await debug.maybe_wait_for_debugger(
251-
child_in_debug=_runtime_vars.get(
249+
child_in_debug=get_runtime_vars().get(
252250
'_debug_mode', False
253251
),
254252
header_msg=(

0 commit comments

Comments
 (0)