From aacfa4e391e8ffc645aa8f0085f03dac73da8ecb Mon Sep 17 00:00:00 2001 From: Stefan Hellander Date: Wed, 3 Jul 2024 22:49:47 +0200 Subject: [PATCH] Fixes bug in find_available if-statement --- fedn/network/loadbalancer/leastpacked.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fedn/network/loadbalancer/leastpacked.py b/fedn/network/loadbalancer/leastpacked.py index 786dd8de0..8e793e95a 100644 --- a/fedn/network/loadbalancer/leastpacked.py +++ b/fedn/network/loadbalancer/leastpacked.py @@ -16,18 +16,16 @@ def find_combiner(self): """Find the combiner with the least number of attached clients. """ - min_clients = None + min_clients = -1 selected_combiner = None - for combiner in self.network.get_combiners(): try: if combiner.allowing_clients(): # Using default default Channel = 1, MODEL_UPDATE_REQUESTS nr_active_clients = len(combiner.list_active_clients()) - if not min_clients or nr_active_clients < min_clients: + if min_clients == -1 or nr_active_clients < min_clients: min_clients = nr_active_clients selected_combiner = combiner except CombinerUnavailableError: pass - return selected_combiner