update primary cron job

This commit is contained in:
MuslemRahimi 2024-08-15 18:31:58 +02:00
parent bbcabce052
commit 189bb23b87

View File

@ -12,12 +12,6 @@ from dotenv import load_dotenv
import os
load_dotenv()
# Create a dictionary to store the status of each job
job_status = {
'options_flow_job': {'running': False},
'options_zero_dte_job': {'running': False}
}
useast_ip_address = os.getenv('USEAST_IP_ADDRESS')
@ -36,16 +30,6 @@ logger.addHandler(handler)
subprocess.run(["timedatectl", "set-timezone", "Europe/Berlin"])
def run_if_not_running(job_func, job_tag):
def wrapper():
if not job_status[job_tag]['running']:
job_status[job_tag]['running'] = True
try:
job_func()
finally:
job_status[job_tag]['running'] = False
return wrapper
# Function to run commands and log output
def run_command(command):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
@ -558,8 +542,8 @@ schedule.every(2).hours.do(run_threaded, run_fda_calendar).tag('fda_calendar_job
schedule.every(3).hours.do(run_threaded, run_json_job).tag('json_job')
schedule.every(6).hours.do(run_threaded, run_analyst_rating).tag('analyst_job')
schedule.every(10).seconds.do(run_threaded, run_if_not_running(run_cron_options_flow, 'options_flow_job')).tag('options_flow_job')
schedule.every(10).seconds.do(run_threaded, run_if_not_running(run_cron_options_zero_dte, 'options_zero_dte_job')).tag('options_zero_dte_job')
schedule.every(10).seconds.do(run_threaded, run_cron_options_flow).tag('options_flow_job')
schedule.every(10).seconds.do(run_threaded, run_cron_options_zero_dte).tag('options_zero_dte_job')
# Run the scheduled jobs indefinitelyp