]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
regrtest: log timeout at startup (GH-19514)
authorVictor Stinner <vstinner@python.org>
Tue, 14 Apr 2020 16:29:44 +0000 (18:29 +0200)
committerGitHub <noreply@github.com>
Tue, 14 Apr 2020 16:29:44 +0000 (18:29 +0200)
Reduce also worker timeout.

Lib/test/libregrtest/main.py
Lib/test/libregrtest/runtest_mp.py

index 1de51b740a98c376447e977801f06a4e7c58245b..95b4856c8bed7d7aefdf14ccea026ff56124d793 100644 (file)
@@ -394,7 +394,10 @@ class Regrtest:
 
         save_modules = sys.modules.keys()
 
-        self.log("Run tests sequentially")
+        msg = "Run tests sequentially"
+        if self.ns.timeout:
+            msg += " (timeout: %s)" % format_duration(self.ns.timeout)
+        self.log(msg)
 
         previous_test = None
         for test_index, test_name in enumerate(self.tests, 1):
index fc12ea7c5fc1469033b014ccbbf8fd7978896759..7a18e45434bb46bc049a7960d0d45edecf81bf5b 100644 (file)
@@ -352,7 +352,11 @@ class MultiprocessTestRunner:
         self.output = queue.Queue()
         self.pending = MultiprocessIterator(self.regrtest.tests)
         if self.ns.timeout is not None:
-            self.worker_timeout = self.ns.timeout * 1.5
+            # Rely on faulthandler to kill a worker process. This timouet is
+            # when faulthandler fails to kill a worker process. Give a maximum
+            # of 5 minutes to faulthandler to kill the worker.
+            self.worker_timeout = min(self.ns.timeout * 1.5,
+                                      self.ns.timeout + 5 * 60)
         else:
             self.worker_timeout = None
         self.workers = None
@@ -360,8 +364,12 @@ class MultiprocessTestRunner:
     def start_workers(self):
         self.workers = [TestWorkerProcess(index, self)
                         for index in range(1, self.ns.use_mp + 1)]
-        self.log("Run tests in parallel using %s child processes"
-                 % len(self.workers))
+        msg = f"Run tests in parallel using {len(self.workers)} child processes"
+        if self.ns.timeout:
+            msg += (" (timeout: %s, worker timeout: %s)"
+                    % (format_duration(self.ns.timeout),
+                       format_duration(self.worker_timeout)))
+        self.log(msg)
         for worker in self.workers:
             worker.start()