From 4e8f1c127f4b63b42215abe2539925629da3e07e Mon Sep 17 00:00:00 2001 From: tdadela Date: Thu, 5 Sep 2024 23:52:35 +0200 Subject: [PATCH] fix(_kl_generator): filter nonpositive weights --- locust/dispatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locust/dispatch.py b/locust/dispatch.py index e58578d979..afde008c8a 100644 --- a/locust/dispatch.py +++ b/locust/dispatch.py @@ -29,7 +29,7 @@ def _kl_generator(users: Iterable[tuple[T, float]]) -> Generator[T | None]: For example, given users A, B with weights 5 and 1 respectively, this algorithm will yield AAABAAAAABAA. """ - heap = [(x * log2(x / (x + 1.0)), x + 1.0, x, name) for name, x in users] + heap = [(x * log2(x / (x + 1.0)), x + 1.0, x, name) for name, x in users if x > 0] if not heap: while True: yield None