get_cpu_usage workaround for Mac

This commit is contained in:
ha7ilm 2016-03-31 10:08:08 +02:00
parent 09f81ab1e7
commit 30e6dd97fa
1 changed files with 4 additions and 1 deletions

View File

@ -617,7 +617,10 @@ last_idletime=0
def get_cpu_usage():
global last_worktime, last_idletime
f=open("/proc/stat","r")
try:
f=open("/proc/stat","r")
except:
return 0 #Workaround, possibly we're on a Mac
line=""
while not "cpu " in line: line=f.readline()
f.close()