Skip to content

Commit

Permalink
Update if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruinsslot committed Nov 28, 2024
1 parent 9e24ae3 commit 1609b84
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions mula/scheduler/schedulers/schedulers/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,35 @@ def push_tasks_for_rescheduling(self):
# When the schedule has no schedule (cron expression), but a
# task is already executed for this schedule we should not run
# the task again
try:
_, count = self.ctx.datastores.task_store.get_tasks(
scheduler_id=self.scheduler_id,
task_type=report_task.type,
filters=filters.FilterRequest(
filters=[
filters.Filter(column="hash", operator="eq", value=report_task.hash),
filters.Filter(column="schedule_id", operator="eq", value=str(schedule.id)),
]
),
)
if count > 0 and schedule.schedule is None:
self.logger.debug(
"Schedule has no schedule, but task already executed",
schedule_id=schedule.id,
if schedule.schedule is None:
try:
_, count = self.ctx.datastores.task_store.get_tasks(
scheduler_id=self.scheduler_id,
task_type=report_task.type,
filters=filters.FilterRequest(
filters=[
filters.Filter(column="hash", operator="eq", value=report_task.hash),
filters.Filter(column="schedule_id", operator="eq", value=str(schedule.id)),
]
),
)
if count > 0:
self.logger.debug(
"Schedule has no schedule, but task already executed",
schedule_id=schedule.id,
scheduler_id=self.scheduler_id,
organisation_id=self.organisation.id,
)
continue
except storage.errors.StorageError as exc_db:
self.logger.error(
"Could not get latest task by hash %s",
report_task.hash,
scheduler_id=self.scheduler_id,
organisation_id=self.organisation.id,
exc_info=exc_db,
)
continue
except storage.errors.StorageError as exc_db:
self.logger.error(
"Could not get latest task by hash %s",
report_task.hash,
scheduler_id=self.scheduler_id,
organisation_id=self.organisation.id,
exc_info=exc_db,
)
continue

executor.submit(self.push_report_task, report_task, self.push_tasks_for_rescheduling.__name__)

Expand Down

0 comments on commit 1609b84

Please sign in to comment.