I have a bunch of workers waiting for tasks (using Django as ORM). My problem is that if there's no task for a given amount of time (whatever MySQL wait_timeout variable is set to) the MySQL connection times out and hence the worker dies.
My first approach to solve this problem was simply to increase the wait_timeout to a higher integer, but I thought a better solution might be to ping MySQL like every 30mins or so if there has been no task to keep the connection alive.
So my question is; how can I using the Django ORM simply ping MySQL to keep the connection alive? What's the best practice here, just do a simple stupid query ?
Setup a connection pool or manually connect the worker as suggested by @ProblemFactory
http://dev.mysql.com/doc/refman/5.6/en/connector-python-connection-pooling.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With