From 052ceb889ec8ea100be6eab810cb06d5febea6fe Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Fri, 14 Jun 2024 11:42:08 +0200 Subject: [PATCH] Enhance code to enqueue greedy variadic components --- haystack/core/pipeline/base.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/haystack/core/pipeline/base.py b/haystack/core/pipeline/base.py index be7c0737d0..9a656552dd 100644 --- a/haystack/core/pipeline/base.py +++ b/haystack/core/pipeline/base.py @@ -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