Skip to content

Commit

Permalink
Fixes KeyError for 'sources' when accessing comsumed source components
Browse files Browse the repository at this point in the history
Also use `stop` instead of `break_current_loop` to control the flow.

Fixes OLCS-510
  • Loading branch information
rhyw committed Mar 28, 2023
1 parent 90c93d0 commit bea9cb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion openlcs/libs/corgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,11 @@ def should_yield_data(component, result):
try:
component = next(components)
except StopIteration:
yield result
# StopIteration may appear when `should_yield_data` is
# False, i.e., the last iteration(before exhausting) may
# accumulates components less than `num_components`.
if len(result) > 1:
yield result
break
else:
subscription_sources, subscription_missings = [], []
Expand Down
2 changes: 1 addition & 1 deletion openlcsd/flow/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ def populate_source_components(context, engine):
source_components = next(generator)
except StopIteration:
# Stop the flow since all chunks are consumed.
engine.break_current_loop()
engine.stop()
else:
context["source_components"] = source_components

Expand Down

0 comments on commit bea9cb7

Please sign in to comment.