Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thecpu_percent
key). However,if (cpuPercent)
also evaluates toFalse
in Javascript ifcpuPercent=0
. That caused the lack of updates whenevercpuPercent=0
.The current fix explicitly checks if they keyword was found by checking that
data[cpu_percent]
was not equal to theundefined
constant.