From 78a3f34f50d640623389e1ca595655675e8c60f1 Mon Sep 17 00:00:00 2001 From: Maximilian Hoerstrup Date: Tue, 21 Nov 2023 11:48:27 +0100 Subject: [PATCH] Use counting loop obj as key for loop counter dict --- pfdl_scheduler/scheduler.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pfdl_scheduler/scheduler.py b/pfdl_scheduler/scheduler.py index 70581f7..c02298c 100644 --- a/pfdl_scheduler/scheduler.py +++ b/pfdl_scheduler/scheduler.py @@ -371,14 +371,14 @@ def on_counting_loop_started( if self.loop_counters.get(task_context.uuid) is None: self.loop_counters[task_context.uuid] = {} - if self.loop_counters[task_context.uuid].get(loop.counting_variable) is None: - self.loop_counters[task_context.uuid][loop.counting_variable] = 0 + if self.loop_counters[task_context.uuid].get(loop) is None: + self.loop_counters[task_context.uuid][loop] = 0 else: - self.loop_counters[task_context.uuid][loop.counting_variable] = ( - self.loop_counters[task_context.uuid][loop.counting_variable] + 1 + self.loop_counters[task_context.uuid][loop] = ( + self.loop_counters[task_context.uuid][loop] + 1 ) - loop_counter = self.loop_counters[task_context.uuid][loop.counting_variable] + loop_counter = self.loop_counters[task_context.uuid][loop] loop_limit = self.get_loop_limit(loop, task_context) if loop_counter < loop_limit: @@ -390,10 +390,6 @@ def on_counting_loop_started( awaited_event = Event(event_type=SET_PLACE, data={"place_id": else_uuid}) self.awaited_events.append(awaited_event) - # loop is done so reset loop counter for this task context - # set it to -1 because it exists now and will be incremented by 1 - self.loop_counters[task_context.uuid][loop.counting_variable] = -1 - # has to be executed at last self.fire_event(awaited_event)