From 2a37c11095e5ed3170ad856d2b403c7b49ab424b Mon Sep 17 00:00:00 2001 From: leondutoit Date: Fri, 21 Aug 2020 13:09:52 +0200 Subject: [PATCH] catch error when there are concurrent attempts to update the postgres schema --- tsdfileapi/db.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tsdfileapi/db.py b/tsdfileapi/db.py index 6e1a628d..0f1bfd85 100644 --- a/tsdfileapi/db.py +++ b/tsdfileapi/db.py @@ -268,9 +268,12 @@ def __init__(self, pool, verbose=False, schema=None, requestor=None): self.requestor = requestor def initialise(self): - with postgres_session(self.pool) as session: - for stmt in self.generator_class.db_init_sql: - session.execute(stmt) + try: + with postgres_session(self.pool) as session: + for stmt in self.generator_class.db_init_sql: + session.execute(stmt) + except psycopg2.InternalError as e: + pass # throws a tuple concurrently updated when restarting many processes return True def tables_list(self):