Skip to content

Commit

Permalink
Use counting loop obj as key for loop counter dict
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhoerstr committed Nov 21, 2023
1 parent 49ad888 commit 2b7b426
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pfdl_scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit 2b7b426

Please sign in to comment.