Skip to content

Commit

Permalink
Fix condition to break while loop awaiting batch completion (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinweisgrau authored Jun 21, 2023
1 parent 5286d64 commit 063f934
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/prefecto/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,11 @@ def _map(self, batches: list[dict[str, list[Any]]]) -> list[PrefectFuture]:
futures = self.task.map(**batch)
results.extend(futures)
# Poll futures to ensure they are not active.
is_processing: bool = False
is_processing: bool = True
while is_processing:
for f in futures:
if not states.is_terminal(f.get_state()):
# If any future is still processing, break and poll again.
is_processing = True
break
else:
# If any future is still processing, loop and poll again.
# If all futures are terminal, break while loop and continue
if all(states.is_terminal(f.get_state()) for f in futures):
is_processing = False

# Map the last batch
Expand Down

0 comments on commit 063f934

Please sign in to comment.