Skip to content

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.

casparvl and others added 5 commits July 8, 2022 18:30
…ent' didn't exist in 'data'. Previously, the update would _also_ be skipped if cpuPercent was zero, which would result in the CPU usage only begin updated _during_ execution of a cell (when CPU usage is non-zero), and it would never return to zero afterwards.
@casparvl
Copy link
Author

Oh, I see my PR branched from a master that contained other changes as well. Let me redo this PR...

@casparvl casparvl closed this Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant