Skip to content

Commit

Permalink
Enhance code to enqueue greedy variadic components
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Jun 14, 2024
1 parent bc17038 commit 052ceb8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions haystack/core/pipeline/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,12 @@ def _distribute_output(

is_greedy = getattr(receiver, "__haystack_is_greedy__", False)
if receiver_socket.is_variadic and is_greedy:
# If the receiver is greedy, we can run it right away.
# If the receiver is greedy, we can run it as soon as possible.
# First we remove it from the status lists it's in if it's there or we risk running it multiple times.
if pair in to_run:
to_run.remove(pair)
if pair in waiting_for_input:
waiting_for_input.remove(pair)
to_run.append(pair)
if pair not in to_run:
to_run.append(pair)

if pair not in waiting_for_input and pair not in to_run:
# Queue up the Component that received this input to run, only if it's not already waiting
Expand Down

0 comments on commit 052ceb8

Please sign in to comment.