I'm wondering how can I create a time-based loop that runs based on a certain interval i.e. something similar to:
while 1:
# do something
time.sleep(1)
but more elegant and "balanced", in the above example if "do something" takes 500ms then the actual loop'll run every 1.5 instead of 1 second, and if this "do something" varies, the loop itself's unstable too.
Any suggestions?
while 1:
# do something
time.sleep(1)
but more elegant and "balanced", in the above example if "do something" takes 500ms then the actual loop'll run every 1.5 instead of 1 second, and if this "do something" varies, the loop itself's unstable too.
Any suggestions?
Comment