from time import time, sleep from threading import Thread from . import scrape from objects import glob def schedule_loop(): if glob.config["scrape"]["run_on_startup"]: scrape.run() while True: _time = time() + glob.config["scrape"]["schedule_seconds"] while _time - time() > 0: sleep(1) scrape.run() thread = Thread(target = schedule_loop) thread.start()