From 9c8c73c3f0a4a022ef0f8924ee13825fbb8781e4 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Sun, 20 Sep 2020 12:36:10 +0200 Subject: [PATCH] Log a warning if on_stop/start have been tagged as tasks (as it is much more likely that the user is confused that this is how it is supposed to be) --- locust/user/task.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/locust/user/task.py b/locust/user/task.py index 7019cb2c96..507d85592f 100644 --- a/locust/user/task.py +++ b/locust/user/task.py @@ -31,6 +31,10 @@ def create_thread(self): """ def decorator_func(func): + if func.__name__ in ["on_stop", "on_start"]: + logging.warning( + "You have tagged your on_stop/start function with @task. This will make the method get called both as a task AND on stop/start." + ) # this is usually not what the user intended func.locust_task_weight = weight return func