Retry to get a connection when an OperationalError is raised
If there are no connection available in the pool, psycopg2 tries to create a new connection but it may raise an OperationalError if the server close it. Closes #13475
This commit is contained in:
1 parent
958090cc27
commit
a4eb342cd7
1 file changed
+1
-1
@@ -264,7 +264,7 @@ class Database(DatabaseInterface):
|
||||
for count in range(retry, -1, -1):
|
||||
try:
|
||||
conn = self._connpool.getconn()
|
||||
except PoolError:
|
||||
except (PoolError, DatabaseOperationalError):
|
||||
if count and not self._connpool.closed:
|
||||
logger.info('waiting a connection')
|
||||
time.sleep(1)
|
||||
|
||||
Reference in new issue
Block a user