From a11f34f7631e87a191a171e4682e2404cc95ebda Mon Sep 17 00:00:00 2001
From: Bastien Abadie <abadie@teklia.com>
Date: Mon, 17 Jun 2024 14:52:27 +0000
Subject: [PATCH] Reset database connection before reconnecting when updating
 export state

---
 arkindex/documents/export/__init__.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arkindex/documents/export/__init__.py b/arkindex/documents/export/__init__.py
index 3c5b3f3a4f..ac1ccd7814 100644
--- a/arkindex/documents/export/__init__.py
+++ b/arkindex/documents/export/__init__.py
@@ -129,6 +129,7 @@ def update_state(corpus_export: CorpusExport, state: CorpusExportState):
         corpus_export.save()
     except (InterfaceError, OperationalError) as e:
         logger.warning(f"Database connection has been lost, retrying: {e}")
+        connections["default"].connection = None
         connections["default"].connect()
         corpus_export.refresh_from_db(using="default")
         corpus_export.state = state
-- 
GitLab