Skip to content

Commit

Permalink
remove unneeded lambda to get the metric values
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Jan 7, 2022
1 parent 6737989 commit 2c89e68
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,7 @@ async def usage_request(self, stream, ident, parent):
return reply_content
current_process = psutil.Process()
all_processes = [current_process] + current_process.children(recursive=True)
process_metric_value = lambda process, name, attribute: self.get_process_metric_value(
process, name, attribute
)
process_metric_value = self.get_process_metric_value
reply_content['kernel_cpu'] = sum([process_metric_value(process, 'cpu_percent', None) for process in all_processes])
reply_content['kernel_memory'] = sum([process_metric_value(process, 'memory_info', 'rss') for process in all_processes])
cpu_percent = psutil.cpu_percent()
Expand Down

0 comments on commit 2c89e68

Please sign in to comment.