I use a 24/7 running flask application with sqlalchemy and postgres DB.
If the DB server goes down (e.g. AWS RDS installs minor upgrades) the (single worker) flask application hangs permanently.
I initialize the SQL extension like this:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
app = Flask(__name__)
db.init_app(app)
The error I get from the DB connection is:
pubnub [ERROR] take message interrupted: (psycopg2.OperationalError) could not connect to server: Connection timed out
Is the server running on host "rdb-dev.xxxxmqtd9et.eu-central-1.rds.amazonaws.com" and accepting TCP/IP connections on port 5432?(Background on this error at: http://sqlalche.me/e/e3q8)
Now the link above points me to the section "Dealing with disconnects" and there some suggestions are made for SQLalchemy. But I have absolutely now idea how to deal with disconnects in flask-sqlalchemy. The init methods are completely different.
Can anybody help with some pointers how to address this issue?