cpython
cpython copied to clipboard
Load averages are unobtainable
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
https://github.com/python/cpython/issues/99242#tasklist-block-44b1c558-681c-4d51-b663-f8879fa2f4dd
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.
@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).
Agreed, there's no real bug here. However, we could just swallow the OSError
and return None at https://github.com/python/cpython/blob/8555dee5aeedb2f37ee2e2216ef8707be0fc1d9d/Lib/test/libregrtest/main.py#L722-L723 since we probably shouldn't actually care there whether we can get the loadavg or not.
@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
Agreed, there's no real bug here. However, we could just swallow the
OSError
and return None athttps://github.com/python/cpython/blob/8555dee5aeedb2f37ee2e2216ef8707be0fc1d9d/Lib/test/libregrtest/main.py#L722-L723
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.
I rebranded this as an enhancement.
It's a enhancement of the tests :)
Merged and backported. Thank you for the fix!