Spaces:
Runtime error
Runtime error
Commit ·
4cb09a6
1
Parent(s): 1680c83
added keep alive args
Browse files
utils.py
CHANGED
|
@@ -59,10 +59,16 @@ class DbEngine:
|
|
| 59 |
|
| 60 |
def connect(self):
|
| 61 |
dbCreds = self.dbCreds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
if self._connection is None or self._connection.closed != 0:
|
| 63 |
self._connection = psycopg2.connect(database=dbCreds.database, user = dbCreds.user,
|
| 64 |
password = dbCreds.password, host = dbCreds.host,
|
| 65 |
-
port = dbCreds.port)
|
| 66 |
|
| 67 |
def getConnection(self):
|
| 68 |
if self._connection is None or self._connection.closed != 0:
|
|
|
|
| 59 |
|
| 60 |
def connect(self):
|
| 61 |
dbCreds = self.dbCreds
|
| 62 |
+
keepaliveKwargs = {
|
| 63 |
+
"keepalives": 1,
|
| 64 |
+
"keepalives_idle": 100,
|
| 65 |
+
"keepalives_interval": 5,
|
| 66 |
+
"keepalives_count": 5,
|
| 67 |
+
}
|
| 68 |
if self._connection is None or self._connection.closed != 0:
|
| 69 |
self._connection = psycopg2.connect(database=dbCreds.database, user = dbCreds.user,
|
| 70 |
password = dbCreds.password, host = dbCreds.host,
|
| 71 |
+
port = dbCreds.port, **keepaliveKwargs)
|
| 72 |
|
| 73 |
def getConnection(self):
|
| 74 |
if self._connection is None or self._connection.closed != 0:
|