[Python-checkins] bpo-36670: regrtest bug fixes (GH-16537)

Miss Islington (bot) webhook-mailer at python.org
Wed Oct 2 07:54:23 EDT 2019


https://github.com/python/cpython/commit/a72de9338882b8013a4bb8adb930fe3308682e28
commit: a72de9338882b8013a4bb8adb930fe3308682e28
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-10-02T04:54:18-07:00
summary:

bpo-36670: regrtest bug fixes (GH-16537)


* Fix TestWorkerProcess.__repr__(): start_time is only valid
  if _popen is not None.
* Fix _kill(): don't set _killed to True if _popen is None.
* _run_process(): only set _killed to False after calling
  run_test_in_subprocess().
(cherry picked from commit 2ea71a07d0a720707094ee55f78fd232c40724bc)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
M Lib/test/libregrtest/runtest_mp.py

diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py
index 38b05781de5fc..a46c78248de39 100644
--- a/Lib/test/libregrtest/runtest_mp.py
+++ b/Lib/test/libregrtest/runtest_mp.py
@@ -120,27 +120,28 @@ def __init__(self, worker_id, pending, output, ns, timeout):
     def __repr__(self):
         info = [f'TestWorkerProcess #{self.worker_id}']
         if self.is_alive():
-            dt = time.monotonic() - self.start_time
-            info.append("running for %s" % format_duration(dt))
+            info.append("running")
         else:
             info.append('stopped')
         test = self.current_test_name
         if test:
             info.append(f'test={test}')
         popen = self._popen
-        if popen:
-            info.append(f'pid={popen.pid}')
+        if popen is not None:
+            dt = time.monotonic() - self.start_time
+            info.extend((f'pid={self._popen.pid}',
+                         f'time={format_duration(dt)}'))
         return '<%s>' % ' '.join(info)
 
     def _kill(self):
-        if self._killed:
-            return
-        self._killed = True
-
         popen = self._popen
         if popen is None:
             return
 
+        if self._killed:
+            return
+        self._killed = True
+
         print(f"Kill {self}", file=sys.stderr, flush=True)
         try:
             popen.kill()
@@ -177,9 +178,10 @@ def _run_process(self, test_name):
 
         self.current_test_name = test_name
         try:
+            popen = run_test_in_subprocess(test_name, self.ns)
+
             self._killed = False
-            self._popen = run_test_in_subprocess(test_name, self.ns)
-            popen = self._popen
+            self._popen = popen
         except:
             self.current_test_name = None
             raise



More information about the Python-checkins mailing list