fix: tell core_probe the lock is held

This commit is contained in:
Abdessamad Derraz committed 2026-10-27 21:03:05 +01:00
1 parent d035a26828
commit 7433d49666
3 files changed
+12 -4

No files matched your search

+8 -3
View File
@@ -29,7 +29,8 @@ or holds under another path.
Each core_probe run holds the host's probe lock (~/.local/state/retrobios/
probe.lock, RETROBIOS_PROBE_LOCK) and releases it before the next: other
probes run between ours. Building and extracting the pack take no lock.
probes run between ours. core_probe is told it is held
(RETROBIOS_PROBE_LOCK_HELD). Building and extracting the pack take no lock.
Usage:
python scripts/pack_probe.py run --platform retroarch [--system sony-playstation]
@@ -85,7 +86,9 @@ VERDICTS = ("boots", "bios_error", "crash", "hang", "unknown")
MAX_ROUNDS = 6
PROBE_TIMEOUT = 900
IDLE_WAIT = 1800
PROBE_LOCK = Path(os.environ.get("RETROBIOS_PROBE_LOCK")
PROBE_LOCK_ENV = "RETROBIOS_PROBE_LOCK"
PROBE_LOCK_HELD_ENV = "RETROBIOS_PROBE_LOCK_HELD"
PROBE_LOCK = Path(os.environ.get(PROBE_LOCK_ENV)
or Path.home() / ".local" / "state" / "retrobios" / "probe.lock")
EXIT_BUSY = 3
@@ -484,8 +487,10 @@ def core_probe(argv: list[str], staged: set[str], layout: Layout, work: Path) ->
with probe_lock():
if "--record" in argv:
wait_idle()
# core_probe takes the same lock unless told its caller holds it.
proc = subprocess.run(command, capture_output=True, text=True, check=False, cwd=ROOT,
timeout=PROBE_TIMEOUT * 2 + 120)
timeout=PROBE_TIMEOUT * 2 + 120,
env={**os.environ, PROBE_LOCK_HELD_ENV: "1", PROBE_LOCK_ENV: str(PROBE_LOCK)})
record = None
if proc.returncode == 0:
try:
+2
View File
@@ -270,6 +270,8 @@ class Lock(unittest.TestCase):
def fake_run(command, **kwargs):
held.append(try_lock())
self.assertEqual(kwargs["env"]["RETROBIOS_PROBE_LOCK_HELD"], "1")
self.assertEqual(kwargs["env"]["RETROBIOS_PROBE_LOCK"], str(lock))
return subprocess.CompletedProcess(command, 2, "", "refused")
lay = layout({"a.bin": 1})
+2 -1
View File
@@ -1081,7 +1081,8 @@ installs it, starts that platform's games. A maintainer starts it, nothing
runs it on a schedule. It takes the host's probe lock
(`~/.local/state/retrobios/probe.lock`, `RETROBIOS_PROBE_LOCK`) around each
`core_probe` run and releases it before the next, so other probes run between
its runs. Never wrap the whole command in `flock`:
its runs, and tells `core_probe` it holds it (`RETROBIOS_PROBE_LOCK_HELD=1`).
Never wrap the whole command in `flock`:
```bash
python scripts/pack_probe.py run --platform retroarch