Write the big boi docs content tree
Replace the ancient `docs/index.rst` (still teaching
`tractor.run()`, `@stream` + arbiters..) with a full ~32 page tree
teaching ONLY the current api (`.wait_for_result()`, registrar
naming, `@context` + `open_context()` as the core model),
- landing: hero example, feature cards + canon links,
- `start/`: install + a 4-example quickstart on-ramp,
- `explain/`: an "SC across processes" essay distilling the essence
per #157's orig ask + a runtime architecture tour,
- `guide/`: 12 task-focused pages incl the flagship multi-process
debugging walkthrough, `Context` + `MsgStream` deep-dives,
cancellation semantics (self-vs-cross cancel rules), discovery,
infected `asyncio`, typed msging + the #126 testing-tips page,
- `api/`: 10 curated autodoc pages (all targets import-verified vs
the reorg'd subpkg tree),
- `project/`: changelog include, ported dev-tips (drops old
`docs/dev_tips.rst`) + roadmap.
Every code block is a `literalinclude` from `examples/`
- zero duplication, all CI-run - w/ `d2` figs floated
into the RHS margin per the 3-col design. Build is green; the 24
remaining warnings all source from lib docstring rst-isms or legacy
`NEWS.rst` content.
Substantially resolves #157 (refine round pending); chips at #175 +
#126.
Prompt-IO: ai/prompt-io/claude/20260611T175152Z_8526985c_prompt_io.md
(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-06-11 19:17:14 +00:00
|
|
|
Runtime and spawning
|
|
|
|
|
====================
|
|
|
|
|
|
|
|
|
|
The core lifecycle API: boot the runtime in your root process,
|
|
|
|
|
spawn trio-"actors" (processes running ``trio.run()`` task trees)
|
|
|
|
|
under a one-cancels-all supervisor, and talk to them through
|
|
|
|
|
portals. This is structured concurrency (SC) applied *transitively*:
|
|
|
|
|
every spawned process is owned by a nursery block and errors
|
|
|
|
|
`always propagate`_. If you can create zombies it **is a bug**.
|
|
|
|
|
|
|
|
|
|
.. currentmodule:: tractor
|
|
|
|
|
|
|
|
|
|
Booting the runtime
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
.. autofunction:: open_root_actor
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
The env vars ``TRACTOR_LOGLEVEL`` and ``TRACTOR_SPAWN_METHOD``
|
|
|
|
|
override the ``loglevel`` / ``start_method`` params so you can
|
|
|
|
|
crank verbosity or swap spawn backends without touching app
|
|
|
|
|
code. Exactly **one** IPC transport may be enabled per actor
|
|
|
|
|
(see ``enable_transports`` and :doc:`/api/ipc`).
|
|
|
|
|
|
|
|
|
|
.. autofunction:: run_daemon
|
|
|
|
|
|
|
|
|
|
Spawning actors
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
.. d2:: diagrams/actor_tree.d2
|
|
|
|
|
:caption: A supervised actor (process) tree.
|
|
|
|
|
:margin:
|
|
|
|
|
:alt: root actor supervising a tree of subactors
|
|
|
|
|
|
|
|
|
|
.. autofunction:: open_nursery
|
|
|
|
|
|
|
|
|
|
.. autoclass:: ActorNursery
|
|
|
|
|
:members: start_actor,
|
|
|
|
|
cancel,
|
|
|
|
|
cancel_called,
|
|
|
|
|
cancelled_caught
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
:meth:`ActorNursery.start_actor` (daemon actor + portal) is the
|
|
|
|
|
blessed spawning primitive; pair it with
|
|
|
|
|
``Portal.open_context()`` for SC-linked remote tasks.
|
Port docs off `run_in_actor` + `Portal.wait_for_result`
The 8-page docs sweep of the #477 removal, ahead of the API's
excision,
- `start/quickstart.rst`: the first-actor-tree walkthrough now
narrates the (migrated) `to_actor.run()` example — no portal
in hand until the daemon section introduces `start_actor()`.
- `guide/spawning.rst`: the one-shot section becomes
`to_actor.run()` (blocking call, placement opts, "built on the
primitives" note); lifetime/teardown rules update — one-shots
never make it to nursery exit since each is reaped inside its
own call.
- `guide/rpc.rst`: the `wait_for_result()` section (an API that
dies with the reap cluster, incl. the `NoResult` sentinel)
becomes a `to_actor.run()` one-shot section.
- `api/core.rst`: drop `run_in_actor`/`wait_for_result` from the
autodoc member lists, drop the `Portal.result()` deprecation
note, add a "One-shot task actors" `tractor.to_actor.run`
autodoc section.
- `guide/{asyncio,context,cancellation,parallelism}.rst`:
mention swaps to the successor API.
Gate: `make -C docs html` builds clean; `to_actor.run` autodoc
renders in `api/core.html`.
(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-07-06 16:31:02 +00:00
|
|
|
|
|
|
|
|
One-shot task actors
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
.. autofunction:: tractor.to_actor.run
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
:func:`tractor.to_actor.run` (parlance of
|
|
|
|
|
``trio.to_thread.run_sync()`` and friends) is the
|
|
|
|
|
*convenience* one-shot — spawn, run a single task, block on
|
|
|
|
|
its result, reap — built entirely on
|
|
|
|
|
:meth:`ActorNursery.start_actor` + :meth:`Portal.run` +
|
|
|
|
|
:meth:`Portal.cancel_actor`, so don't design around it as the
|
|
|
|
|
core model. It supersedes the removed (legacy, non-blocking)
|
|
|
|
|
``ActorNursery.run_in_actor()``.
|
Write the big boi docs content tree
Replace the ancient `docs/index.rst` (still teaching
`tractor.run()`, `@stream` + arbiters..) with a full ~32 page tree
teaching ONLY the current api (`.wait_for_result()`, registrar
naming, `@context` + `open_context()` as the core model),
- landing: hero example, feature cards + canon links,
- `start/`: install + a 4-example quickstart on-ramp,
- `explain/`: an "SC across processes" essay distilling the essence
per #157's orig ask + a runtime architecture tour,
- `guide/`: 12 task-focused pages incl the flagship multi-process
debugging walkthrough, `Context` + `MsgStream` deep-dives,
cancellation semantics (self-vs-cross cancel rules), discovery,
infected `asyncio`, typed msging + the #126 testing-tips page,
- `api/`: 10 curated autodoc pages (all targets import-verified vs
the reorg'd subpkg tree),
- `project/`: changelog include, ported dev-tips (drops old
`docs/dev_tips.rst`) + roadmap.
Every code block is a `literalinclude` from `examples/`
- zero duplication, all CI-run - w/ `d2` figs floated
into the RHS margin per the 3-col design. Build is green; the 24
remaining warnings all source from lib docstring rst-isms or legacy
`NEWS.rst` content.
Substantially resolves #157 (refine round pending); chips at #175 +
#126.
Prompt-IO: ai/prompt-io/claude/20260611T175152Z_8526985c_prompt_io.md
(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-06-11 19:17:14 +00:00
|
|
|
|
|
|
|
|
.. deprecated:: 0.1.0a6
|
|
|
|
|
|
|
|
|
|
``ActorNursery.cancelled`` warns; use
|
|
|
|
|
:attr:`ActorNursery.cancel_called` and
|
|
|
|
|
:attr:`ActorNursery.cancelled_caught`. The ``rpc_module_paths``
|
|
|
|
|
kwarg is likewise deprecated in favor of ``enable_modules``.
|
|
|
|
|
|
|
|
|
|
Portals
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
A :class:`Portal` "opens a portal" into a peer actor's memory
|
|
|
|
|
domain: you call functions and start SC-linked tasks *over IPC* as
|
|
|
|
|
though they were local, with results, errors and cancellation
|
|
|
|
|
flowing back `exactly like trio`_.
|
|
|
|
|
|
|
|
|
|
.. autoclass:: Portal
|
|
|
|
|
:members: run,
|
|
|
|
|
run_from_ns,
|
|
|
|
|
open_stream_from,
|
|
|
|
|
cancel_actor,
|
|
|
|
|
chan
|
|
|
|
|
|
|
|
|
|
.. deprecated:: 0.1.0a6
|
|
|
|
|
|
Port docs off `run_in_actor` + `Portal.wait_for_result`
The 8-page docs sweep of the #477 removal, ahead of the API's
excision,
- `start/quickstart.rst`: the first-actor-tree walkthrough now
narrates the (migrated) `to_actor.run()` example — no portal
in hand until the daemon section introduces `start_actor()`.
- `guide/spawning.rst`: the one-shot section becomes
`to_actor.run()` (blocking call, placement opts, "built on the
primitives" note); lifetime/teardown rules update — one-shots
never make it to nursery exit since each is reaped inside its
own call.
- `guide/rpc.rst`: the `wait_for_result()` section (an API that
dies with the reap cluster, incl. the `NoResult` sentinel)
becomes a `to_actor.run()` one-shot section.
- `api/core.rst`: drop `run_in_actor`/`wait_for_result` from the
autodoc member lists, drop the `Portal.result()` deprecation
note, add a "One-shot task actors" `tractor.to_actor.run`
autodoc section.
- `guide/{asyncio,context,cancellation,parallelism}.rst`:
mention swaps to the successor API.
Gate: `make -C docs html` builds clean; `to_actor.run` autodoc
renders in `api/core.html`.
(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-07-06 16:31:02 +00:00
|
|
|
The str-form ``Portal.run('mod.path', 'fn_name')`` warns;
|
Write the big boi docs content tree
Replace the ancient `docs/index.rst` (still teaching
`tractor.run()`, `@stream` + arbiters..) with a full ~32 page tree
teaching ONLY the current api (`.wait_for_result()`, registrar
naming, `@context` + `open_context()` as the core model),
- landing: hero example, feature cards + canon links,
- `start/`: install + a 4-example quickstart on-ramp,
- `explain/`: an "SC across processes" essay distilling the essence
per #157's orig ask + a runtime architecture tour,
- `guide/`: 12 task-focused pages incl the flagship multi-process
debugging walkthrough, `Context` + `MsgStream` deep-dives,
cancellation semantics (self-vs-cross cancel rules), discovery,
infected `asyncio`, typed msging + the #126 testing-tips page,
- `api/`: 10 curated autodoc pages (all targets import-verified vs
the reorg'd subpkg tree),
- `project/`: changelog include, ported dev-tips (drops old
`docs/dev_tips.rst`) + roadmap.
Every code block is a `literalinclude` from `examples/`
- zero duplication, all CI-run - w/ `d2` figs floated
into the RHS margin per the 3-col design. Build is green; the 24
remaining warnings all source from lib docstring rst-isms or legacy
`NEWS.rst` content.
Substantially resolves #157 (refine round pending); chips at #175 +
#126.
Prompt-IO: ai/prompt-io/claude/20260611T175152Z_8526985c_prompt_io.md
(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
2026-06-11 19:17:14 +00:00
|
|
|
pass a function *object* whose module is listed in the target's
|
|
|
|
|
``enable_modules``. ``Portal.channel`` is the legacy spelling
|
|
|
|
|
of :attr:`Portal.chan`.
|
|
|
|
|
|
|
|
|
|
.. autofunction:: tractor._context.open_context_from_portal
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
:func:`~tractor._context.open_context_from_portal` is bound as
|
|
|
|
|
the **method-alias** ``Portal.open_context()`` — that's the
|
|
|
|
|
spelling you should actually call:
|
|
|
|
|
``portal.open_context(fn, **kwargs)``. See :doc:`/api/context`
|
|
|
|
|
for the full ``Context`` + ``MsgStream`` API it unlocks.
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
:meth:`Portal.cancel_actor` cancels the *whole* remote runtime
|
|
|
|
|
and process (machine-level), not a single task — use
|
|
|
|
|
:meth:`Context.cancel` for task-level cancellation. Pass
|
|
|
|
|
``raise_on_timeout=True`` to get an ``ActorTooSlowError`` you
|
|
|
|
|
can escalate per SC discipline (see :doc:`/api/errors`).
|
|
|
|
|
|
|
|
|
|
Clusters
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
.. autofunction:: open_actor_cluster
|
|
|
|
|
|
|
|
|
|
Spawn a *flat* cluster of ``count`` worker actors (default: one
|
|
|
|
|
per core) all serving the RPC ``modules`` list, yielding a
|
|
|
|
|
``dict[str, Portal]`` keyed by actor name. Handy for
|
|
|
|
|
embarrassingly parallel fan-out; see ``examples/quick_cluster.py``.
|
|
|
|
|
|
|
|
|
|
Runtime introspection
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
.. autofunction:: current_actor
|
|
|
|
|
|
|
|
|
|
.. autoclass:: Actor
|
|
|
|
|
:members: aid,
|
|
|
|
|
name,
|
|
|
|
|
uid,
|
|
|
|
|
is_registrar,
|
|
|
|
|
is_infected_aio,
|
|
|
|
|
cancel_soon
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
:class:`Actor` is the per-process runtime singleton (msg loop,
|
|
|
|
|
RPC scheduling, IPC server) — you never instantiate it yourself
|
|
|
|
|
and should normally only touch the identity/introspection
|
|
|
|
|
surface listed above. The canonical identity type is
|
|
|
|
|
:attr:`Actor.aid` (a ``tractor.msg.Aid`` struct);
|
|
|
|
|
:attr:`Actor.uid` is the legacy ``(name, uuid)`` 2-tuple which
|
|
|
|
|
is still pervasive in logs and error metadata.
|
|
|
|
|
|
|
|
|
|
.. deprecated:: 0.1.0a6
|
|
|
|
|
|
|
|
|
|
``Actor.is_arbiter`` warns; use :attr:`Actor.is_registrar`.
|
|
|
|
|
The ``arbiter_addr`` constructor kwarg is deprecated for
|
|
|
|
|
``registry_addrs``.
|
|
|
|
|
|
|
|
|
|
.. autofunction:: current_ipc_ctx
|
|
|
|
|
|
|
|
|
|
.. autofunction:: is_root_process
|
|
|
|
|
|
|
|
|
|
.. autofunction:: get_runtime_vars
|
|
|
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
|
|
:doc:`/api/context` for the SC-linked remote task API,
|
|
|
|
|
:doc:`/api/discovery` for finding actors by name, and the
|
|
|
|
|
guided tours in :doc:`/guide/spawning`, :doc:`/guide/rpc` and
|
|
|
|
|
:doc:`/guide/context`.
|
|
|
|
|
|
|
|
|
|
.. _always propagate: https://trio.readthedocs.io/en/latest/design.html#exceptions-always-propagate
|
|
|
|
|
.. _exactly like trio: https://trio.readthedocs.io/en/latest/reference-core.html#cancellation-semantics
|