importtime#wait if load average is too highdef load_average_wait(treshold=1):
"""
If server is above the treshold value, wait for lower load before continue
"""whilefloat(open("/proc/loadavg").readline().split(" ")[:3][0])> treshold:
time.sleep(10)# my script part that eat a lot...whileTrue:
# Encode video, is there anything else eating so much cpu in the universe ?
encode_video()# wait if cpu start boiling...
load_average_wait(1.5)

import time
#wait if load average is too high
def load_average_wait(treshold=1):
"""
If server is above the treshold value, wait for lower load before continue
"""
while float(open("/proc/loadavg").readline().split(" ")[:3][0]) > treshold:
time.sleep(10)
# my script part that eat a lot...
while True:
# Encode video, is there anything else eating so much cpu in the universe ?
encode_video()
# wait if cpu start boiling...
load_average_wait(1.5)