mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-40094: Add test.support.wait_process() (GH-19254)
Moreover, the following tests now check the child process exit code: * test_os.PtyTests * test_mailbox.test_lock_conflict() * test_tempfile.test_process_awareness() * test_uuid.testIssue8621() * multiprocessing resource tracker tests
This commit is contained in:
parent
400e1dbcad
commit
278c1e159c
19 changed files with 125 additions and 103 deletions
|
@ -727,30 +727,19 @@ class HandlerTest(BaseTest):
|
|||
|
||||
locks_held__ready_to_fork.wait()
|
||||
pid = os.fork()
|
||||
if pid == 0: # Child.
|
||||
if pid == 0:
|
||||
# Child process
|
||||
try:
|
||||
test_logger.info(r'Child process did not deadlock. \o/')
|
||||
finally:
|
||||
os._exit(0)
|
||||
else: # Parent.
|
||||
else:
|
||||
# Parent process
|
||||
test_logger.info(r'Parent process returned from fork. \o/')
|
||||
fork_happened__release_locks_and_end_thread.set()
|
||||
lock_holder_thread.join()
|
||||
start_time = time.monotonic()
|
||||
while True:
|
||||
test_logger.debug('Waiting for child process.')
|
||||
waited_pid, status = os.waitpid(pid, os.WNOHANG)
|
||||
if waited_pid == pid:
|
||||
break # child process exited.
|
||||
if time.monotonic() - start_time > 7:
|
||||
break # so long? implies child deadlock.
|
||||
time.sleep(0.05)
|
||||
test_logger.debug('Done waiting.')
|
||||
if waited_pid != pid:
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
waited_pid, status = os.waitpid(pid, 0)
|
||||
self.fail("child process deadlocked.")
|
||||
self.assertEqual(status, 0, msg="child process error")
|
||||
|
||||
support.wait_process(pid, exitcode=0)
|
||||
|
||||
|
||||
class BadStream(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue