问题
I have a series of python scripts that are designed to be long running. When I look at the MySQL process monitor, I see that three of them will always have a time of 0, then 2 of them that I use to actually insert data into the database will have values that are always counting up, and never get reset to 0 meaning that eventually they encounter the dreaded 'MySQL has gone away'.
I am using MySQLdb.
Can someone please explain why this happens?
Is there a way to make sure that they reset this value to 0?
Thanks
回答1:
It sounds like your idle timeout is expiring. This is set in the mysqld server configuration, though, and is not really an issue with MySQLdb. You need to adjust the wait-timeout system variable, either in the server configuration, or with an SQL statement when you connect.
来源:https://stackoverflow.com/questions/12564828/sleeping-processes-in-mysql