python every x seconds code example
Example 1: run every minute python
from time import time, sleep
while True:
sleep(60 - time() % 60)
# thing to run
Example 2: python timer loop
import sched, time
s = sched.scheduler(time.time, time.sleep)
def do_something(sc):
print("Doing stuff...")
# do your stuff
s.enter(60, 1, do_something, (sc,))
s.enter(60, 1, do_something, (s,))
s.run()