Advay Umare
Advay Umare

Reputation: 432

How to handle database disconnects while using mysql jobstore with Flask Sqlalchemy

I am using Flask Sqlalchemy and have given mysql as job store while initiating the Scheduler. But Sometimes when I add job to scheduler it throws 'Mysql Server has gone away' error probably client has disconnected..Can anyone suggest if we can handle this using some event listeners and reconnect to the database..

Upvotes: 2

Views: 811

Answers (1)

Edgar Henriquez
Edgar Henriquez

Reputation: 1383

MySQL closes it self the stale connections (8 hours of inactivity by default). You can set the pool recycle to solve this problem.

app.config["SQLALCHEMY_POOL_RECYCLE"] = 300

more info.

Upvotes: 1

Related Questions