Repository navigation
fix(execution): let one process at a time follow the runs in a runs folder - #263
Merged
Merged
Conversation
…older Two Nullius processes on one profile both resumed every live run: the run log held each line twice and both wrote run.json. restore now holds an flock on the runs folder's .lock for the rest of the process, and a second nullius serve on that folder stops with one line. The lock goes with the process. With --debug, the reloader's watcher leaves the runs to the server it starts.
harenome
force-pushed
the
fix/one-server-per-profile
branch
from
November 20, 2026 13:16
77a0ff4 to
50b5e7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #257
What
execution.restorenow takes an exclusive, non-blockingfcntl.flockon<runs folder>/.lockand holds it until the process ends. It takes it before it reads a record. A second process on the same runs folder getsexecution.Followed.app.pyturns that into one line and exit status 1:The kernel releases the lock when its process ends, however it ends, so a crash leaves nothing to clean up. A second
restorein the same process reuses the lock it holds.app.pynow callsrestorebefore it opens or creates a workspace, so a refused start writes nothing. With--debug, the reloader's watcher process runsmaintoo. It now leaves the runs to the server process it starts (werkzeug.serving.is_running_from_reloader). Before this change, both of those processes resumed the runs (read from the code, not run).The second server is refused. It does not start read-only. A server that does not follow the runs would still show them, take Stop and Continue on records it does not follow, and start new runs that only it knows of. Each of these needs its own guard. A refusal keeps one writer for every
run.json, and the message says what to do. The lock is on the runs folder, not on the profile, because the runs folder is what two processes share: two profiles with oneRUNS_DIRare refused too. The suite's modules, each with its own temporary runs folder, do not block each other.Windows is not a target:
executionalready importsfcntlthroughnullius.standard, and runs are POSIX shell scripts.Touches
backend (
nullius/execution.py) ·app/app.py· docs (docs/builder.md) · testsVerified
In a rootless Podman container (
python:3.12, withuvfor the Harbor build fixtures):python3 app/tests/parallel.py: 3107 tests in 158 modules, OK.pip install -r app/requirements.txt, thenpython3 app/tests/parallel.py app/ui_tests: 560 tests in 57 modules, OK.tests/test_execution_recovery.py,Restart.test_a_second_process_on_one_runs_root_resumes_nothing. It records a running part, lets the first process go, and starts two processes that each callrestoreon the same root. One resumes the run, and the other is refused. The log says "Nullius is back" once, and the next part is launched once. After both processes end, arestorein the test process is not refused. On main, it fails: both processes resume the run, and each log line appears twice.ui_tests/test_run_routes.py,ReopenAtStart.test_a_second_server_on_the_runs_folder_stops_with_one_line: the start exits with the message, and--debugin the reloader's watcher calls norestore.test_execution_two_instances.py) passes on this branch.python3 app/app.py --port 5099running, a secondpython3 app/app.py --port 5098printed the line above and exited 1. Withpython3 app/app.py --debug --port 5097running, the page answered 200 and a second server was refused.Not checked: a second server started while a live host run is followed.
Risk
flocksupport (some network mounts) may refuse every start, or lock nothing. A runs folder that cannot be created takes no lock, as before, when there was nothing to restore.NULLIUS_HOMEorRUNS_DIR..lockfile left in the runs folder is ignored: a run name cannot start with a dot.