Commit d938ee3f authored by Anthony Jacob's avatar Anthony Jacob
Browse files

try dirtyfix for connection loss

parent 3d3c55cf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -39,6 +39,16 @@ def error404(error):
                "NODE_DIR": app.config["NODE_DIR"],
            },), 404

#preping is not enough 
#https://github.com/psycopg/psycopg2/issues/829  
@app.before_request
def check_connection():
    app.logger.info(f"pass into check connection")
    try:
        db.session.execute(text("SELECT 1"))
    except Exception as e:
        app.logger.error(f"Database connection check failed: {e}")
        db.session.rollback()  # Reset the session

app.register_blueprint(blueprint_filter)