iac_test/parser_api/scheduler.py
dm1sh c40a1b4f92
FInished work
(Too lazy to split by commits)
2023-09-21 20:41:56 +03:00

26 lines
547 B
Python

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()