Skip to content

Ignore load averages if getloadavg is unavailable #99242

Closed

Description

@zhuofeng6

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

Activity

  1. ronaldoussoren commented on Nov 8, 2022

    @ronaldoussoren
    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.

  2. added
    pendingThe issue will be closed if no feedback is provided
    on Nov 8, 2022
  3. ronaldoussoren commented on Nov 17, 2022

    @ronaldoussoren
    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).

  4. zware commented on Nov 17, 2022

    @zware
    Member

    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.

  5. zhuofeng6 commented on Nov 18, 2022

    @zhuofeng6
    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

  6. ronaldoussoren commented on Nov 24, 2022

    @ronaldoussoren
    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.

  7. removed
    pendingThe issue will be closed if no feedback is provided
    on Nov 24, 2022
  8. added
    type-featureA feature request or enhancement
    and removed
    type-bugAn unexpected behavior, bug, or error
    on Jun 27, 2023
  9. changed the title [-]Load averages are unobtainable[/-] [+]Ignore Load averages are unobtainable[/+] on Jun 27, 2023
  10. changed the title [-]Ignore Load averages are unobtainable[/-] [+]Ignore load averages if getloadavg is unavailable[/+] on Jun 27, 2023
  11. erlend-aasland commented on Jun 27, 2023

    @erlend-aasland
    Contributor

    I rebranded this as an enhancement.

  12. added a commit that references this issue on Jul 13, 2023
  13. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 27, 2023
  14. added a commit that references this issue on Jul 13, 2024
  15. added 2 commits that reference this issue on Jul 13, 2024
  16. added a commit that references this issue on Jul 13, 2024
  17. added a commit that references this issue on Jul 17, 2024
  18. added a commit that references this issue on Jul 22, 2024
  19. encukou commented on Jul 22, 2024

    @encukou
    Member

    It's a enhancement of the tests :)

    Merged and backported. Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    easystdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions