From fcb165e5d194b630ddc33ee301cc696235b6d9e7 Mon Sep 17 00:00:00 2001 From: Gabe Joseph Date: Mon, 21 Jun 2021 15:27:33 -0600 Subject: [PATCH] No randomness if < 10 workers to choose from Fixes flaky `test_balance_with_restrictions` --- distributed/scheduler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distributed/scheduler.py b/distributed/scheduler.py index 708f9161902..3fd7326df1d 100644 --- a/distributed/scheduler.py +++ b/distributed/scheduler.py @@ -7501,6 +7501,8 @@ def decide_worker( sample_from = idle_workers or worker_pool candidates.update( random.choices(list(sample_from), k=min(10, len(sample_from))) + if len(sample_from) > 10 + else sample_from ) if valid_workers is None: if not candidates: