mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 10:34:23 +01:00
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:
1 file changed
+16
-1
@@ -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
|
||||
Reference in new issue
Block a user