locustio/locust · error · ValueError
There are no users with weight > 0.
Error message
There are no users with weight > 0.
What it means
Environment filters out user classes whose weight is 0 (and fixed_count 0). If filtering removes every user class, no load can be generated, so it raises ValueError (noted in source as needing a better exception type).
Source
Thrown at locust/env.py:267
else:
exclude_tags = None
for user_class in self.user_classes:
filter_tasks_by_tags(user_class, tags, exclude_tags)
def _remove_user_classes_with_weight_zero(self) -> None:
"""
Remove user classes having a weight of zero.
"""
if len(self.user_classes) == 0:
# Preserve previous behaviour that allowed no user classes to be specified.
return
filtered_user_classes = [
user_class for user_class in self.user_classes if user_class.weight > 0 or user_class.fixed_count > 0
]
if len(filtered_user_classes) == 0:
# TODO: Better exception than `ValueError`?
raise ValueError("There are no users with weight > 0.")
self.user_classes[:] = filtered_user_classes
def assign_equal_weights(self) -> None:
"""
Update the user classes such that each user runs their specified tasks with equal
probability.
"""
for u in self.user_classes:
u.weight = 1
user_tasks: list[TaskSet | Callable] = []
tasks_frontier = u.tasks
while len(tasks_frontier) != 0:
t = tasks_frontier.pop()
if isinstance(t, TaskHolder):
tasks_frontier.extend(t.tasks)
elif callable(t):
if t not in user_tasks:
user_tasks.append(t)View on GitHub (pinned to f391a716e1)
Solutions
- Give at least one user class a weight > 0 (or a fixed_count > 0)
- If a class should be excluded, keep another active class in the list
- Validate weights before constructing Environment
Example fix
// before env = Environment(user_classes=[UserA]) # UserA.weight = 0 // after UserA.weight = 1 env = Environment(user_classes=[UserA])
Defensive patterns
Strategy: validation
Validate before calling
classes = [UserA, UserB] assert any(getattr(c, "weight", 1) > 0 or getattr(c, "fixed_count", 0) > 0 for c in classes), "need at least one user with weight > 0" env = Environment(user_classes=classes)
Try / catch
try:
env = Environment(user_classes=classes)
except ValueError as e:
if "no users with weight" in str(e):
raise RuntimeError("Enable at least one user class (weight > 0)") from e
raise Prevention
- Never set weight=0 on every class in a run
- Sanity-check config-driven weights before constructing Environment
- Keep at least one default active class
When it happens
Trigger: Setting `weight = 0` on all user classes passed to Environment(user_classes=[...]); passing an empty list of user classes where all get filtered; dynamically zeroing weights via config to 'disable' the only user class.
Common situations: Driving user weights from a config file where all weights resolve to 0; disabling a single-class test by setting weight 0; typos in config keys so weight defaults are lost.
Related errors
- You must specify the base host. Either in the host attribute
- 'uri' must be provided for MilvusUser
- 'collection_name' must be provided for MilvusUser
- Invalid timeout.
- You need to set OPENAI_API_KEY env var to use OpenAIUser
AI-assisted analysis of locustio/locust@f391a716e1 (2026-08-29).
Data as JSON: /api/errors/19a13f3238b93ece.
Report an issue: GitHub.