Skip to content

Commit 73274f0

Browse files
committed
Use polling on macOS
1 parent c60cf34 commit 73274f0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/simple_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,16 @@ def __init__(self, p: subprocess.Popen):
133133
self.p = p
134134

135135
def wait(self, timeout: Optional[float] = None) -> Any:
136-
return self.p.communicate(timeout=timeout)
136+
if sys.platform != "darwin":
137+
return self.p.communicate(timeout=timeout)
138+
139+
# On macOS, communicate() with a timeout can be flaky, so we poll.
140+
start_time = time.monotonic()
141+
while self.p.poll() is None:
142+
if timeout is not None and time.monotonic() - start_time >= timeout:
143+
raise subprocess.TimeoutExpired(self.p.args, timeout)
144+
time.sleep(0.032)
145+
return self.p.communicate()
137146

138147
@property
139148
def returncode(self) -> int:

0 commit comments

Comments
 (0)