From cea77ab377314110900b4b0bf5ec553f27ff54cc Mon Sep 17 00:00:00 2001 From: vijay59122 Date: Mon, 28 Oct 2024 09:57:47 +0530 Subject: [PATCH] --tags filter issue(#2849) fix --- locust/user/task.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/locust/user/task.py b/locust/user/task.py index 11089b9772..96f7b92c7c 100644 --- a/locust/user/task.py +++ b/locust/user/task.py @@ -472,13 +472,15 @@ class DefaultTaskSet(TaskSet): def get_next_task(self): if not self.user.tasks: + warning_message = "Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)" if getattr(self.user, "task", None): - extra_message = ", but you have set a 'task' attribute on your class - maybe you meant to set 'tasks'?" + extra_message = f", but you have set a 'task' attribute on your class - maybe you meant to set 'tasks'?" + raise Exception( + f"No tasks defined on {self.user.__class__.__name__}{extra_message}{warning_message}" + ) else: - extra_message = "." - raise Exception( - f"No tasks defined on {self.user.__class__.__name__}{extra_message} Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)" - ) + logger.warning(f"No tasks defined on {self.user.__class__.__name__}. {warning_message}") + raise StopUser return random.choice(self.user.tasks) def execute_task(self, task):