Reputation: 317
I know this issue is not a new one on SO but I'm unable to find a solution. Whenever I return to my desk after leaving my app running overnight, I get a MySQL server has gone away
error that persists until I restart my uwsgi service. I've already done the following:
pool_recycle=
some really large number in my create_engine()
callping_connection()
after a @event.listens_for()
decorator (and I can't use pool_pre_ping
- that breaks my create_engine()
call)/etc/my.cnf
I added wait_timeout
and interactive_timeout
params with large valuesbut nothing has had any effect.
Upvotes: 0
Views: 525
Reputation: 36
From the sqlalchemy doc located here, the pool_recycle feature is what you are looking for.
from sqlalchemy import create_engine
engine = create_engine("mysql://scott:tiger@localhost/test", pool_recycle=28700)
Set pool_recycle to a value < wait_timeout in your mysql configuration file my.cnf
MySQL default wait_time is 28800 (8 hrs)
Dont forget to restart your services (i.e. mysql, etc) if you do modify the conf files
Upvotes: 1