Skip to content

Commit 8f1b17f

Browse files
committed
fix(tests): stabilize child process cleanup under CI load
1 parent 7a2e591 commit 8f1b17f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/client/test_stdio.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,17 @@ def handle_term(sig, frame):
480480
# Let child start writing
481481
await anyio.sleep(0.5)
482482

483-
# Verify child is writing
483+
# Verify child is writing. This can be slow/flaky under CI load, so poll up to a bounded timeout.
484484
if os.path.exists(marker_file): # pragma: no branch
485-
size1 = os.path.getsize(marker_file)
486-
await anyio.sleep(0.3)
487-
size2 = os.path.getsize(marker_file)
488-
assert size2 > size1, "Child should be writing"
485+
initial_size = os.path.getsize(marker_file)
486+
deadline = anyio.current_time() + 5.0
487+
while anyio.current_time() < deadline:
488+
await anyio.sleep(0.1)
489+
current_size = os.path.getsize(marker_file)
490+
if current_size > initial_size: # pragma: no branch
491+
break
492+
else: # pragma: no cover
493+
raise AssertionError("Child should be writing")
489494

490495
# Terminate - this will kill the process group even if parent exits first
491496
await _terminate_process_tree(proc)

0 commit comments

Comments
 (0)