From 41d6484106e21408c233525f980936df403db26c Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Wed, 11 Dec 2024 10:31:19 +0100 Subject: [PATCH] Treat exceptions in init event handler as fatal and shut down locust right away. --- locust/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/locust/main.py b/locust/main.py index 67b278f8a1..91b449e4f9 100644 --- a/locust/main.py +++ b/locust/main.py @@ -544,6 +544,9 @@ def assign_equal_weights(environment, **kwargs): # Fire locust init event which can be used by end-users' code to run setup code that # need access to the Environment, Runner or WebUI. environment.events.init.fire(environment=environment, runner=runner, web_ui=web_ui) + if log.unhandled_greenlet_exception: + # treat exceptions in init handlers as fatal. They are already logged so no need to log anything more. + sys.exit(1) if web_ui: web_ui.start()