Update quickstart `we_are_processes` walkthrough
The reworked `we_are_processes.py` (now `Context`-API based) prints different stdout, so the hardcoded expected-output block went stale: swap the old `Yo, i'm 'worker_N'...` / "self-destruct in 1 sec" lines for the real run - "self-destruct in 2s.." then the per-worker `Started ep-task in subactor,` / `N::'worker_N'@<pid>` blocks. Also retell the prose to match: subs spawn concurrently from bg `trio` tasks, each runs a `@tractor.context` `endpoint()` that `ctx.started()`-hands its name + pid back through `Portal.open_context()`, then parks in `trio.sleep_forever()` before the root crashes + the tree is reaped. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codedocs_vibed_for_serious
parent
274cab948c
commit
c028e03d32
|
|
@ -144,26 +144,41 @@ breakfast - run this while monitoring your process tree::
|
||||||
``_subactor[worker_0@<pid>]``, so ``pstree``/``htop``/
|
``_subactor[worker_0@<pid>]``, so ``pstree``/``htop``/
|
||||||
``pgrep -f`` can tell your actors apart at a glance.
|
``pgrep -f`` can tell your actors apart at a glance.
|
||||||
|
|
||||||
You'll see something like::
|
You'll see something like (one subactor per core - 24 on this box,
|
||||||
|
trimmed here)::
|
||||||
|
|
||||||
$ python examples/parallelism/we_are_processes.py
|
$ python examples/parallelism/we_are_processes.py
|
||||||
Yo, i'm 'worker_2' running in pid 1777246
|
This tree will self-destruct in 2s..
|
||||||
Yo, i'm 'worker_0' running in pid 1777244
|
|
||||||
Yo, i'm 'worker_3' running in pid 1777247
|
Started ep-task in subactor,
|
||||||
Yo, i'm 'worker_1' running in pid 1777245
|
0::'worker_0'@218140
|
||||||
This process tree will self-destruct in 1 sec...
|
|
||||||
|
Started ep-task in subactor,
|
||||||
|
2::'worker_2'@218134
|
||||||
|
|
||||||
|
Started ep-task in subactor,
|
||||||
|
1::'worker_1'@218137
|
||||||
|
|
||||||
|
Started ep-task in subactor,
|
||||||
|
3::'worker_3'@218132
|
||||||
|
|
||||||
Zombies Contained
|
Zombies Contained
|
||||||
|
|
||||||
(The worker lines land in whatever order the OS schedules them;
|
(The ``Started ep-task`` lines land in whatever order the OS
|
||||||
they're separate *processes*, racing, and that's the point.)
|
schedules them; they're separate *processes*, racing, and that's
|
||||||
|
the point.)
|
||||||
|
|
||||||
An actor is spawned per core, each parks itself in
|
One subactor is spawned per core - concurrently, from background
|
||||||
``trio.sleep_forever()``... and then the root *crashes on
|
``trio`` tasks, so each child's cold ``import tractor`` overlaps
|
||||||
purpose*. The ``ActorNursery`` responds with hard ``trio``
|
instead of stacking. Each runs a ``@tractor.context``
|
||||||
discipline: every child is cancelled, every process is reaped,
|
``endpoint()`` that ``ctx.started()``-hands its name and pid back
|
||||||
the error propagates to ``trio.run()``, and your terminal prints
|
through ``Portal.open_context()`` (those ``Started ep-task``
|
||||||
``Zombies Contained``. No orphans, no ``kill -9`` archaeology in
|
lines), then parks in ``trio.sleep_forever()``. Then the root
|
||||||
``htop`` afterwards.
|
*crashes on purpose* and the ``ActorNursery`` responds with hard
|
||||||
|
``trio`` discipline: every child is cancelled, every process is
|
||||||
|
reaped, the error propagates to ``trio.run()``, and your terminal
|
||||||
|
prints ``Zombies Contained``. No orphans, no ``kill -9``
|
||||||
|
archaeology in ``htop`` afterwards.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue