Skip to content

Commit

Permalink
align with main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Jun 9, 2022
1 parent 835753f commit ab441b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,12 @@ async def usage_request(self, stream, ident, parent):
for process in self.processes.values()
]
)
host_cpu_percent = psutil.cpu_percent()
cpu_percent = psutil.cpu_percent()
# https://psutil.readthedocs.io/en/latest/index.html?highlight=cpu#psutil.cpu_percent
# The first time cpu_percent is called it will return a meaningless 0.0 value which you are supposed to ignore.
if host_cpu_percent is not None and host_cpu_percent != 0.0:
reply_content["host_cpu_percent"] = host_cpu_percent
if cpu_percent is not None and cpu_percent != 0.0:
reply_content["host_cpu_percent"] = cpu_percent
reply_content["cpu_count"] = psutil.cpu_count(logical=True)
reply_content["host_virtual_memory"] = dict(psutil.virtual_memory()._asdict())
reply_msg = self.session.send(stream, "usage_reply", reply_content, parent, ident)
self.log.debug("%s", reply_msg)
Expand Down

0 comments on commit ab441b7

Please sign in to comment.