Added failed tasks status management.

pull/684/head
Louis Vézina 5 years ago
parent 7977deb142
commit f825917c9d

@ -15,7 +15,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.triggers.cron import CronTrigger from apscheduler.triggers.cron import CronTrigger
from apscheduler.triggers.date import DateTrigger from apscheduler.triggers.date import DateTrigger
from apscheduler.events import EVENT_JOB_SUBMITTED, EVENT_JOB_EXECUTED from apscheduler.events import EVENT_JOB_SUBMITTED, EVENT_JOB_EXECUTED, EVENT_JOB_ERROR
from datetime import datetime from datetime import datetime
import pytz import pytz
from tzlocal import get_localzone from tzlocal import get_localzone
@ -72,14 +72,18 @@ global running_tasks
running_tasks = [] running_tasks = []
def task_listener(event): def task_listener_add(event):
if event.job_id not in running_tasks:
running_tasks.append(event.job_id)
def task_listener_remove(event):
if event.job_id in running_tasks: if event.job_id in running_tasks:
running_tasks.remove(event.job_id) running_tasks.remove(event.job_id)
else:
running_tasks.append(event.job_id)
scheduler.add_listener(task_listener, EVENT_JOB_SUBMITTED | EVENT_JOB_EXECUTED) scheduler.add_listener(task_listener_add, EVENT_JOB_SUBMITTED)
scheduler.add_listener(task_listener_remove, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)
def schedule_update_job(): def schedule_update_job():

Loading…
Cancel
Save