Is there any portable way for a Python process to query its own system CPU load?
If the "ps" command exists I could run it and parse the results, but that's less than desirable.
you can use psutil:
import os
import psutil
pid = os.getpid()
p = psutil.Process(pid)
pct = p.get_cpu_percent(interval=1.0)
print(pct)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With