From 939b7cdfb2287887f03a10a6141f41565d9db2e2 Mon Sep 17 00:00:00 2001 From: Kevin Diem Date: Wed, 12 Jul 2023 21:58:20 -0400 Subject: [PATCH 1/3] GH-99242 Catch OSError when calling getloadavg --- Lib/test/libregrtest/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 9001ca33b6166a..b46e5987a43570 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -769,7 +769,10 @@ def getloadavg(self): return self.win_load_tracker.getloadavg() if hasattr(os, 'getloadavg'): - return os.getloadavg()[0] + try: + return os.getloadavg()[0] + except OSError: + pass return None From 543609d246a6aa9b846d4992fa680276c23bde88 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 02:14:58 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst diff --git a/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst b/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst new file mode 100644 index 00000000000000..e25846f1133450 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst @@ -0,0 +1 @@ +When running regression tests under certain conditions (such as chroot) it was possible that calls to `os.getloadavg` would throw. This PR catches OS errors as reporting load average is optional. From 772e6fe76812264c169031c5a721e83240d24ccc Mon Sep 17 00:00:00 2001 From: Kevin Diem Date: Thu, 13 Jul 2023 05:48:05 -0400 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst Co-authored-by: Charlie Zhao --- .../next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst b/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst index e25846f1133450..c5dd3d2bdc322f 100644 --- a/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst +++ b/Misc/NEWS.d/next/Tests/2023-07-13-02-14-57.gh-issue-99242.DHVhbD.rst @@ -1 +1,3 @@ -When running regression tests under certain conditions (such as chroot) it was possible that calls to `os.getloadavg` would throw. This PR catches OS errors as reporting load average is optional. +: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.