Skip to content

Ignore load averages if getloadavg is unavailable #99242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zhuofeng6 opened this issue Nov 8, 2022 · 7 comments
Closed

Ignore load averages if getloadavg is unavailable #99242

zhuofeng6 opened this issue Nov 8, 2022 · 7 comments
Labels
easy stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@zhuofeng6
Copy link

zhuofeng6 commented Nov 8, 2022

when i run chroot compile /home/abuild/rpmbuild/BUILD/Python-3.9.9/build/debug/python -m test.regrtest test_mailbox -wW

output:

Traceback (most recent call last):
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/regrtest.py", line 47, in <module>
    _main()
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/regrtest.py", line 43, in _main
    main()
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 733, in main
    Regrtest().main(tests=tests, **kwargs)
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 655, in main
    self._main(tests, kwargs)
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 708, in _main
    self.run_tests()
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 535, in run_tests
    self.run_tests_sequential()
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 417, in run_tests_sequential
    self.log(msg)
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 145, in log
    load_avg = self.getloadavg()
  File "/home/abuild/rpmbuild/BUILD/Python-3.9.9/Lib/test/libregrtest/main.py", line 668, in getloadavg
    return os.getloadavg()[0]
OSError: Load averages are unobtainable

os:openeuler22.03

Linked PRs

@zhuofeng6 zhuofeng6 added the type-bug An unexpected behavior, bug, or error label Nov 8, 2022
@ronaldoussoren
Copy link
Contributor

You appear to be running the tests in a chroot environment? Is the proc filesystem mounted in that environment?

os.getloadavg() is a thin wrapper around getloadavg(3), which with glibc on linux loads information from a file in /proc.

@ronaldoussoren ronaldoussoren added the pending The issue will be closed if no feedback is provided label Nov 8, 2022
@ronaldoussoren
Copy link
Contributor

@alittlesir, could you please answer my question?

Given the implementation of os.getloadavg() I'm pretty sure this is not a bug in CPython, but in the setup of the environment where you run the tests (e.g. not having /proc mounted there).

@zware
Copy link
Member

zware commented Nov 17, 2022

Agreed, there's no real bug here. However, we could just swallow the OSError and return None at

if hasattr(os, 'getloadavg'):
return os.getloadavg()[0]
since we probably shouldn't actually care there whether we can get the loadavg or not.

@zhuofeng6
Copy link
Author

@alittlesir, could you please answer my question?

Given the implementation of os.getloadavg() I'm pretty sure this is not a bug in CPython, but in the setup of the environment where you run the tests (e.g. not having /proc mounted there).

yes, you are right, it is not a bug in CPython, because it is only happened in the chroot environment, i am sorry to waste your time

@ronaldoussoren
Copy link
Contributor

Agreed, there's no real bug here. However, we could just swallow the OSError and return None at

if hasattr(os, 'getloadavg'):
return os.getloadavg()[0]

since we probably shouldn't actually care there whether we can get the loadavg or not.

Agreed, the function is optional and we might as well ignore errors when calling it. Reporting the load average during test runs is not the most important part of running those tests.

@ronaldoussoren ronaldoussoren removed the pending The issue will be closed if no feedback is provided label Nov 24, 2022
@erlend-aasland erlend-aasland added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jun 27, 2023
@erlend-aasland erlend-aasland changed the title Load averages are unobtainable Ignore Load averages are unobtainable Jun 27, 2023
@erlend-aasland erlend-aasland changed the title Ignore Load averages are unobtainable Ignore load averages if getloadavg is unavailable Jun 27, 2023
@erlend-aasland
Copy link
Contributor

I rebranded this as an enhancement.

kgdiem added a commit to kgdiem/cpython that referenced this issue Jul 13, 2023
@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 27, 2023
encukou pushed a commit that referenced this issue Jul 13, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 13, 2024
…in conditions. (pythonGH-121663)

(cherry picked from commit 0759cec)

Co-authored-by: Bas Bloemsaat <[email protected]>
Co-Authored-By: Kevin Diem <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 13, 2024
…in conditions. (pythonGH-121663)

(cherry picked from commit 0759cec)

Co-authored-by: Bas Bloemsaat <[email protected]>
Co-Authored-By: Kevin Diem <[email protected]>
encukou pushed a commit that referenced this issue Jul 13, 2024
…ain conditions. (GH-121663) (GH-121670)

gh-99242 Ignore error when running regression tests under certain conditions. (GH-121663)
(cherry picked from commit 0759cec)

Co-authored-by: Bas Bloemsaat <[email protected]>
Co-authored-by: Kevin Diem <[email protected]>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
encukou pushed a commit that referenced this issue Jul 22, 2024
…ain conditions. (GH-121663) (GH-121669)

(cherry picked from commit 0759cec)

Co-authored-by: Bas Bloemsaat <[email protected]>
Co-authored-by: Kevin Diem <[email protected]>
@encukou encukou added the tests Tests in the Lib/test dir label Jul 22, 2024
@encukou
Copy link
Member

encukou commented Jul 22, 2024

It's a enhancement of the tests :)

Merged and backported. Thank you for the fix!

@encukou encukou closed this as completed Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

6 participants