[issue34060] regrtest: log "CPU usage" on Windows

Giampaolo Rodola' report at bugs.python.org
Tue Jul 24 14:39:10 EDT 2018


Giampaolo Rodola' <g.rodola at gmail.com> added the comment:

> PR 8287 seems short to me and it seems like psutils doesn't expose Processor Queue Length, so I'm not sure why we are talking about depending on psutils?

I'm not sure if you're strictly interested in getting system load or if CPU utilization is also fine. FWIW with psutil you would be able to get the system-wide CPU utilization occurred in a given period of time:

>>> import psutil, time
>>> psutil.cpu_percent(interval=None)  # non-blocking
0.0
>>> time.sleep(60)
>>> psutil.cpu_percent(interval=None)  # average of the last 60 secs
23.6
>>>

...and you can do the same for the current process too (psutil.Process().cpu_percent()).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34060>
_______________________________________


More information about the Python-bugs-list mailing list