mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Add test.support.busy_retry() (#93770)
Add busy_retry() and sleeping_retry() functions to test.support.
This commit is contained in:
parent
4e9fa71d7e
commit
7e9eaad864
12 changed files with 186 additions and 99 deletions
|
@ -2,7 +2,6 @@
|
|||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
import unittest
|
||||
from test.fork_wait import ForkWait
|
||||
|
@ -22,14 +21,12 @@ class Wait4Test(ForkWait):
|
|||
# Issue #11185: wait4 is broken on AIX and will always return 0
|
||||
# with WNOHANG.
|
||||
option = 0
|
||||
deadline = time.monotonic() + support.SHORT_TIMEOUT
|
||||
while time.monotonic() <= deadline:
|
||||
for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
|
||||
# wait4() shouldn't hang, but some of the buildbots seem to hang
|
||||
# in the forking tests. This is an attempt to fix the problem.
|
||||
spid, status, rusage = os.wait4(cpid, option)
|
||||
if spid == cpid:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
self.assertEqual(spid, cpid)
|
||||
self.assertEqual(os.waitstatus_to_exitcode(status), exitcode)
|
||||
self.assertTrue(rusage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue