diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-31 18:08:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 18:08:12 (GMT) |
commit | 278c1e159c970da6cd6683d18c6211f5118674cc (patch) | |
tree | be6eb27edca136282245e7ce374a23ba05f25cf7 /Lib/test/test_logging.py | |
parent | 400e1dbcad93061f1f7ab4735202daaa5e731507 (diff) | |
download | cpython-278c1e159c970da6cd6683d18c6211f5118674cc.zip cpython-278c1e159c970da6cd6683d18c6211f5118674cc.tar.gz cpython-278c1e159c970da6cd6683d18c6211f5118674cc.tar.bz2 |
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
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index e223522..2ad3c5c 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -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): |