locustio/locust · error · LocustError
No tasks defined. Use the @task decorator or set the 'tasks'
Error message
No tasks defined. Use the @task decorator or set the 'tasks' attribute of the SequentialTaskSet
What it means
SequentialTaskSet.get_next_task() cycles through self.tasks in order; if the tasks list is empty there is nothing to cycle, so it raises LocustError with guidance to define tasks via @task or the tasks attribute.
Source
Thrown at locust/user/sequential_taskset.py:63
class SequentialTaskSet(TaskSet, metaclass=SequentialTaskSetMeta):
"""
Class defining a sequence of tasks that a User will execute.
Works like TaskSet, but task weight is ignored, and all tasks are executed in order. Tasks can
either be specified by setting the *tasks* attribute to a list of tasks, or by declaring tasks
as methods using the @task decorator. The order of declaration decides the order of execution.
It's possible to combine a task list in the *tasks* attribute, with some tasks declared using
the @task decorator. The order of declaration is respected also in that case.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._task_cycle = cycle(self.tasks)
def get_next_task(self):
if not self.tasks:
raise LocustError(
"No tasks defined. Use the @task decorator or set the 'tasks' attribute of the SequentialTaskSet"
)
return next(self._task_cycle)
View on GitHub (pinned to f391a716e1)
Solutions
- Add at least one @task decorated method to the SequentialTaskSet class
- Or set the 'tasks' attribute to a non-empty list of task callables/classes
- Verify the class you're running is the one with tasks defined (check inheritance and that tasks aren't filtered out by tags at runtime)
Example fix
// before
class MyFlow(SequentialTaskSet):
pass
// after
class MyFlow(SequentialTaskSet):
@task
def step_one(self):
self.client.get("/") Defensive patterns
Strategy: validation
Validate before calling
if not getattr(MyFlow, "tasks", None):
raise RuntimeError("SequentialTaskSet has no tasks defined") Type guard
def has_tasks(cls) -> bool:
return bool(getattr(cls, "tasks", None)) or any(hasattr(v, "locust_task_weight") for v in vars(cls).values()) Try / catch
try:
flow = MyFlow(user)
except LocustError as e:
if "No tasks defined" in str(e):
logging.error(f"{type(flow).__name__} lacks tasks")
raise Prevention
- Give every TaskSet/SequentialTaskSet at least one @task method
- Check spelling of the 'tasks' attribute
- Instantiate task classes in CI smoke tests to catch empty definitions early
When it happens
Trigger: Instantiating a SequentialTaskSet subclass with no @task methods and no tasks attribute (or an empty list), then the runner calls get_next_task() when executing the user.
Common situations: Empty placeholder TaskSet classes; tasks defined only on a base class in a way Locust doesn't pick up; conditional task registration that ended up empty; typos like assigning 'task' instead of 'tasks'.
Related errors
- The 'tasks' attribute can only be set to list or dict
- No Markov tasks defined in class {classname}. Use the @trans
- In order to use a with-block for requests, you must also pas
- Tried to set status on a request that has not yet been made.
- If you want to change the state of the request using .succes
AI-assisted analysis of locustio/locust@f391a716e1 (2026-08-29).
Data as JSON: /api/errors/99cb7e8bd91977d2.
Report an issue: GitHub.