From 9733828897c75bea3c3b39f0cd5f86ddad285e68 Mon Sep 17 00:00:00 2001 From: Peery Date: Mon, 3 Jan 2022 20:26:13 +0100 Subject: [PATCH] Added DB connection timeout Added a timeout of 3 seconds when trying to connect to the database. --- ArtNet/db/db_adapter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ArtNet/db/db_adapter.py b/ArtNet/db/db_adapter.py index cde9cdc..d60eb17 100644 --- a/ArtNet/db/db_adapter.py +++ b/ArtNet/db/db_adapter.py @@ -11,7 +11,8 @@ class DBAdapter: self.db = None self.db_cursor = None try: - self.db = psycopg2.connect(host=host, port=port, database=database, user=user, password=password) + self.db = psycopg2.connect(host=host, port=port, database=database, user=user, password=password, + connect_timeout=3) self.db_cursor = self.db.cursor() except psycopg2.OperationalError as e: