]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-99242 Ignore error when running regression tests under certain conditions...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 13 Jul 2024 10:24:17 +0000 (12:24 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 10:24:17 +0000 (12:24 +0200)
gh-99242 Ignore error when running regression tests under certain conditions. (GH-121663)
(cherry picked from commit 0759cecd9d945dfbac2226febaba51f41195555c)

Co-authored-by: Bas Bloemsaat <bas@bloemsaat.com>
Co-authored-by: Kevin Diem <kg.diem@gmail.com>
Lib/test/libregrtest/logger.py
Misc/NEWS.d/next/Tests/2024-07-13-11-04-44.gh-issue-99242.aGxnwz.rst [new file with mode: 0644]

index a125706927393c5b46553e8e9bd46d143c6f5cae..fa1d4d575c8fd4f21e261f5a9c7518b77e20b1b6 100644 (file)
@@ -43,7 +43,10 @@ class Logger:
 
     def get_load_avg(self) -> float | None:
         if hasattr(os, 'getloadavg'):
-            return os.getloadavg()[0]
+            try:
+                return os.getloadavg()[0]
+            except OSError:
+                pass
         if self.win_load_tracker is not None:
             return self.win_load_tracker.getloadavg()
         return None
diff --git a/Misc/NEWS.d/next/Tests/2024-07-13-11-04-44.gh-issue-99242.aGxnwz.rst b/Misc/NEWS.d/next/Tests/2024-07-13-11-04-44.gh-issue-99242.aGxnwz.rst
new file mode 100644 (file)
index 0000000..7d904f2
--- /dev/null
@@ -0,0 +1,3 @@
+:func:`os.getloadavg` may throw :exc:`OSError` when running regression tests
+under certain conditions (e.g. chroot). This error is now caught and
+ignored, since reporting load average is optional.