Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exceptions in on_stop #2402

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions locust/user/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,19 @@ def run(self):
else:
self.wait()
except InterruptTaskSet as e:
self.on_stop()
try:
self.on_stop()
except Exception:
logging.error("Uncaught exception in on_stop: \n%s", traceback.format_exc())
if e.reschedule:
raise RescheduleTaskImmediately(e.reschedule) from e
else:
raise RescheduleTask(e.reschedule) from e
except (StopUser, GreenletExit):
self.on_stop()
try:
self.on_stop()
except Exception:
logging.error("Uncaught exception in on_stop: \n%s", traceback.format_exc())
raise
except Exception as e:
self.user.environment.events.user_error.fire(user_instance=self, exception=e, tb=e.__traceback__)
Expand Down