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 (grafted from cecbc1736f2d0fdd8a77c1dcdfe81e23cf99f451) --HG-- branch : 7.0
This commit is contained in:
@@ -259,7 +259,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