From ccf41bec7912abf0a33a72a342fcb0d5194f21a4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Wed, 29 Mar 2023 15:00:31 +0200 Subject: [PATCH] Retry select after half a second --- kdb-bot/src/bot_data/db_context.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kdb-bot/src/bot_data/db_context.py b/kdb-bot/src/bot_data/db_context.py index 6e11f284..46eff3bb 100644 --- a/kdb-bot/src/bot_data/db_context.py +++ b/kdb-bot/src/bot_data/db_context.py @@ -1,3 +1,5 @@ +import time + from cpl_core.database import DatabaseSettings from cpl_core.database.context import DatabaseContext @@ -31,4 +33,9 @@ class DBContext(DatabaseContext): return super(DBContext, self).select(statement) except Exception as e: self._logger.error(__name__, f"Database error caused by {statement}", e) + try: + time.sleep(0.5) + return self.select(statement) + except Exception as e: + pass return []