v1.7.0 hotfix #634
This commit is contained in:
commit
e2627fe1cc
2 changed files with 7 additions and 4 deletions
|
|
@ -75,9 +75,11 @@ class PostgresClient:
|
|||
connection = None
|
||||
cursor = None
|
||||
long_query = False
|
||||
unlimited_query = False
|
||||
|
||||
def __init__(self, long_query=False, unlimited_query=False):
|
||||
self.long_query = long_query
|
||||
self.unlimited_query = unlimited_query
|
||||
if unlimited_query:
|
||||
long_config = dict(_PG_CONFIG)
|
||||
long_config["application_name"] += "-UNLIMITED"
|
||||
|
|
@ -85,7 +87,7 @@ class PostgresClient:
|
|||
elif long_query:
|
||||
long_config = dict(_PG_CONFIG)
|
||||
long_config["application_name"] += "-LONG"
|
||||
long_config["options"] = f"-c statement_timeout={config('pg_long_timeout', cast=int, default=5*60) * 1000}"
|
||||
long_config["options"] = f"-c statement_timeout={config('pg_long_timeout', cast=int, default=5 * 60) * 1000}"
|
||||
self.connection = psycopg2.connect(**long_config)
|
||||
else:
|
||||
self.connection = postgreSQL_pool.getconn()
|
||||
|
|
@ -99,11 +101,11 @@ class PostgresClient:
|
|||
try:
|
||||
self.connection.commit()
|
||||
self.cursor.close()
|
||||
if self.long_query:
|
||||
if self.long_query or self.unlimited_query:
|
||||
self.connection.close()
|
||||
except Exception as error:
|
||||
print("Error while committing/closing PG-connection", error)
|
||||
if str(error) == "connection already closed":
|
||||
if str(error) == "connection already closed" and not self.long_query and not self.unlimited_query:
|
||||
print("Recreating the connexion pool")
|
||||
make_pool()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1171,4 +1171,5 @@ def get_limits(context: schemas.CurrentContext = Depends(OR_context)):
|
|||
@public_app.put('/', tags=["health"])
|
||||
@public_app.delete('/', tags=["health"])
|
||||
def health_check():
|
||||
return {"data": f"live {config('version_number', default='')}"}
|
||||
return {"data": {"stage": f"live {config('version_number', default='')}",
|
||||
"internalCrons": config("LOCAL_CRONS", default=False, cast=bool)}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue