how to make python do something every x seconds

Solutions on MaxInterview for how to make python do something every x seconds by the best coders in the world

showing results for - "how to make python do something every x seconds"
Marco
20 Apr 2017
1import sched, time
2s = sched.scheduler(time.time, time.sleep)
3def do_something(sc): 
4    print("Doing stuff...")
5    # do your stuff
6    s.enter(60, 1, do_something, (sc,))
7
8s.enter(60, 1, do_something, (s,))
9s.run()
10