From 2bddc07f6990c1a60fb58864bad22e39fa427600 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Fri, 22 Apr 2022 14:03:37 +0200 Subject: [PATCH] Timescale listener: recreate dbconn if it is closed, should help if for some reason the connection is closed (for some reason) before logging end time. --- locust_plugins/listeners.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/locust_plugins/listeners.py b/locust_plugins/listeners.py index 49906c5..3de0c7b 100644 --- a/locust_plugins/listeners.py +++ b/locust_plugins/listeners.py @@ -82,6 +82,8 @@ def __init__( def dbcursor(self): with self.dblock: try: + if self.dbconn.closed: + self.dbconn = self._dbconn() yield self.dbconn.cursor() except psycopg2.Error: try: