import threading import time import schedule def run_continuously(interval=1): cease_continuous_run = threading.Event() class ScheduleThread(threading.Thread): @classmethod def run(cls): while not cease_continuous_run.is_set(): schedule.run_pending() time.sleep(interval) continuous_thread = ScheduleThread() continuous_thread.start() return cease_continuous_run.set def run_threaded(job): job_thread = threading.Thread(target=job) job_thread.start()