Skip to content

Commit a542c71

Browse files
committed
Handle ProcessLookupError in wait calls for subprocesses in test_eintr
1 parent cb8d874 commit a542c71

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/_test_eintr.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ def _test_wait_multiple(self, wait_func):
101101
wait_func()
102102
# Call the Popen method to avoid a ResourceWarning
103103
for proc in processes:
104-
proc.wait()
104+
try:
105+
proc.wait()
106+
except ProcessLookupError:
107+
# Process already exited, which is expected but not always raised
108+
pass
105109

106110
def test_wait(self):
107111
self._test_wait_multiple(os.wait)
@@ -114,7 +118,11 @@ def _test_wait_single(self, wait_func):
114118
proc = self.new_sleep_process()
115119
wait_func(proc.pid)
116120
# Call the Popen method to avoid a ResourceWarning
117-
proc.wait()
121+
try:
122+
proc.wait()
123+
except ProcessLookupError:
124+
# Process already exited, which is expected but not always raised
125+
pass
118126

119127
def test_waitpid(self):
120128
self._test_wait_single(lambda pid: os.waitpid(pid, 0))

0 commit comments

Comments
 (0)