Skip to content

Commit

Permalink
Catch exceptions in on_stop. Fixes #2401
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Sep 21, 2023
1 parent 9074fc8 commit df3d0d7
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit df3d0d7

Please sign in to comment.