Merge pull request #642 from elder-plinius/test/mcp-crash-windows-esrch-race

Tolerate ESRCH in the mcp crash-window test wait helper
This commit is contained in:
Joseph Magly authored and GitHub committed 2026-11-24 19:30:09 -05:00
commit 20a09c61b2
1 file changed
+16 -1
+16 -1
View File
@@ -28,7 +28,9 @@ def wait_for(predicate):
value = predicate()
if value:
return value
except (FileNotFoundError, json.JSONDecodeError):
except (FileNotFoundError, ProcessLookupError, json.JSONDecodeError):
# A /proc entry can vanish between an existence check and the read
# (ESRCH); the next poll observes the process as gone.
pass
time.sleep(.01)
pytest.fail('synthetic process transition timed out')
@@ -179,3 +181,16 @@ def test_forged_identity_cannot_signal_a_real_unrelated_process(tmp_path):
finally:
unrelated.kill()
unrelated.wait(timeout=5)
def test_wait_for_tolerates_a_process_vanishing_between_check_and_read():
"""A /proc entry that disappears mid-read raises ESRCH; that is a transient state."""
calls = iter([ProcessLookupError(3, 'No such process'), True])
def predicate():
value = next(calls)
if isinstance(value, BaseException):
raise value
return value
assert wait_for(predicate) is True