Forums

Changing MySql connection timeout when using external scheduled script

I've tried to find a best solution to database timeout (have searched and read a lot). I'm using web2py and use an external script under schedule to send emails from the database. However, I want to do this every 15 minutes (not every hour).

I use a file lock method to start a scheduled script with for loop, which updates the lock file and doesn't start another task if it's running, so that's ok. However, after sleeping 15 minutes the database connection is lost. This means I'd need to restart the whole script (web2py models) or increase database timeout.

Restarting web2py script would require a subprocess call or something from the scheduled script and seems complex. For me the simplest would be to increase my database timeout. Is this possible to do manually for my own MySql database under pythonanywhere? Or is there a better way?

The best solution would be to reconnect to the database when the connection drops. I would suggest checking on the web2py forums for details of how to do that.

The timeout for MySQL is for everyone and so we can't raise it just for you.

Thanks. I understand.