Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

test(platform): tell a reaped clipboard helper from a stranger with its PID (#614)

Ruben Lütkeb4aba3e135b8
diff --git a/tests/unit/platform/test_clipboard_reader.py b/tests/unit/platform/test_clipboard_reader.py
index 6d24b1cd06..41a40cec0d 100644
--- a/tests/unit/platform/test_clipboard_reader.py
+++ b/tests/unit/platform/test_clipboard_reader.py
@@ -78,7 +78,21 @@ def test_stalled_reader_process_is_reaped(monkeypatch, tmp_path):
assert reader.read_with_deadline() is None
assert time.monotonic() - started < 5
assert pid_file.exists(), "the helper must have started for this test to prove cleanup"
- assert not psutil.pid_exists(int(pid_file.read_text()))
+ assert not _helper_still_runs(int(pid_file.read_text()), str(pid_file))
+
+
+def _helper_still_runs(pid: int, marker: str) -> bool:
+ """Whether the process with this PID is still the helper, by its command line.
+
+ Windows hands a finished process's PID to the next process it starts. On a
+ runner with four test workers that happens within milliseconds, so
+ ``pid_exists`` alone can name a stranger and fail the test for a helper
+ that was reaped.
+ """
+ try:
+ return marker in " ".join(psutil.Process(pid).cmdline())
+ except (psutil.NoSuchProcess, psutil.AccessDenied):
+ return False
@pytest.mark.skipif(sys.platform != "win32", reason="windowed Windows pipe contract")