You signed in with
8000
another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vivarium: move the runner from bare asyncio to anyio structured concurrency #949
vivarium's session, CLI and control already use anyio. The runner (pkgs/vivarium-runner) is bare asyncio: about 60 call sites in 9 modules, most in machine.py (29), then arpyc.py, cluster.py, qmp.py.
What to replace, by count: get_running_loop (14), wait_for (10), sleep (9), TimeoutError (7), gather (4), ensure_future (3), Task/Future, Queue, create_subprocess_exec, StreamReader, Lock.
Why it matters:
Machine holds loose tasks (ensure_future for the console pump), so a crash in one is invisible until something awaits it. A task group owns them and cancels the rest on failure.
wait_for + TimeoutError become fail_after/move_on_after, with anyio's cancellation scopes instead of asyncio's edge cases.
The console guests design (docs/design/console-guests.md, Run MikroTik RouterOS as a vivarium guest #945) adds anyio code beside Machine. Mixing the two families is where cancellation stops behaving.
Shape: module by module, machine.py last. A ruff TID251 banned-api rule on asyncio in the runner, so it cannot come back. arpyc keeps its protocol; only its transport moves to anyio streams.
One more site: pkgs/vivarium/vivarium/cloud.py (Cloud, #1408). It starts its boots and notices with asyncio.ensure_future, waits with asyncio.timeout and asyncio.sleep, and keeps asyncio.Events on Instance. Those tasks outlive the API call that starts them, so the move needs a task group the session owns for its whole life. Its unit tests (pkgs/vivarium/tests/test_cloud.py) run under asyncio.run.
Activity
docs(vivarium): the console guests design, as built
Lillecarl commentedon Nov 17, 2026
One more site:
pkgs/vivarium/vivarium/cloud.py(Cloud, #1408). It starts its boots and notices withasyncio.ensure_future, waits withasyncio.timeoutandasyncio.sleep, and keepsasyncio.Events onInstance. Those tasks outlive the API call that starts them, so the move needs a task group the session owns for its whole life. Its unit tests (pkgs/vivarium/tests/test_cloud.py) run underasyncio.run.Assisted-By: Claude Opus 5.5
Lillecarl commentedon Nov 17, 2026
Measurements from the vivarium review (#1444).
nix/shared/ruff-anyio.tomlmissesasyncio.ensure_future,start_unix_server,open_unix_connectionandfrom asyncio import subprocess. With these unbanned, the lint sees 13 of about 23 unstructured sites inpkgs/. vivarium: lint gates, the anyio ban list, and the house rules they would enforce #1487 extends the list.Backend.launchandstoreview.buildare synchronous on the loop (S1: about 0.3 s per guest, in series).anyio.to_threadgets itsdie_with_parenthelpers SIGKILLed when the worker thread retires, after 10 s idle.Assisted-By: Claude Opus 5.5
vivarium: use anyio in the check scripts, the tests and the host's cloud
vivarium: use anyio in the check scripts, the tests and the host's cloud
vivarium: the agent serves the cloud API from an anyio listener
vivarium: a session holds its cloud's tasks in a task group
vivarium: an agent channel is served in its owner's task group