Skip to content

Conversation

@kgdiem
Copy link
Contributor

@kgdiem kgdiem commented Jul 13, 2023

Per suggestions in the comments for #99242 I added a try/except around the call to os.getloadavg.

Perhaps a logged warning here is appropriate as well?

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@ghost
Copy link

ghost commented Jul 13, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@kgdiem kgdiem requested a review from CharlieZhao95 July 13, 2023 09:48
return os.getloadavg()[0]
try:
return os.getloadavg()[0]
except OSError:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The raised exception does not have any other information that .args == ('Load averages are unobtainable',), so it's ok if we don't inspect it more to make sure we're catching only the issue at hand.

Copy link

@StyXman StyXman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on a CentOS 7.9 chroot without /proc mounted. On newer OSs /proc is not used but a syscall sysinfo().

@encukou
Copy link
Member

encukou commented Jul 13, 2024

Merged in #121663. Thank you for the fix!

@encukou encukou closed this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants