Skip to content
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

Fix update at zero cpu #147

Merged
merged 1 commit into from
Oct 3, 2022

Conversation

casparvl
Copy link

I encountered what seems to be a bug in jupyter-resource-usage. The CPU percentage would not be updated, unless we were actually executing code. The result of this was that, after cells had completed and the CPU was idling (0% CPU usage), the displayed percentage would be stuck at the last non-zero value.

I traced the cause to this line. Most likely, the intend there was to make sure the CPU usage wasn't displayed if the API endpoint didn't register a CPU usage (i.e. if data didn't contain the cpu_percent key). However, if (cpuPercent) also evaluates to False in Javascript if cpuPercent=0. That caused the lack of updates whenever cpuPercent=0.

The current fix explicitly checks if they keyword was found by checking that data[cpu_percent] was not equal to the undefined constant.

…nt' didn't exist in the 'data'. Previously, the update would not only be skipped if the key didn't exist, but _also_ if the cpuPercent was zero, which would result in the CPU usage only being updated _during_ execution of a cell (when CPU usage is non-zero), and it would never return to zero afterwards
@jtpio jtpio force-pushed the fix_updates_at_zero_cpu branch from dd7601f to 9415a48 Compare October 3, 2022 12:27
@jtpio
Copy link
Member

jtpio commented Oct 3, 2022

Rebased to grab the CI fix from #145.

@jtpio jtpio added the bug label Oct 3, 2022
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

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

Thanks!

@jtpio jtpio merged commit 186b1fa into jupyter-server:master Oct 3, 2022
@welcome
Copy link

welcome bot commented Oct 3, 2022

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants