Python - how to check system boot?

I am writing a script to validate the given URLs and resolve the IP address. I would like to fix this, so I decided to transfer it to several threads. However, I want to make sure that the scripts do not overload the server on which it runs. The question arises: how to check system loading in a script? Or is there a way to determine how many threads can be started simultaneously?

+8
source share
2 answers

Try psutil ( https://github.com/giampaolo/psutil ):

import psutil
psutil.cpu_percent()

EDIT 2019/04/26: psutil now implements and emulates getloadavg () also on Windows:

 >>> psutil.getloadavg()
 (3.14, 3.89, 4.67)
+4
source

, , :

>>> import os
>>> os.getloadavg()
(0.66, 0.69, 0.58)

, , , .

+17

All Articles