I have a cyclone web service that is negotiating with a MySQL database. If there is no activity for some time (more than 8 hours, I guess), I get the following error until I restart the web service:
_mysql_exceptions.OperationalError: (2006, "MySQL server is gone")
I saw this post regarding cp_reconnect , and I implemented this when creating the connection pool:
pool = adbapi.ConnectionPool("MySQLdb", host=self.host, user=self.user, passwd=self.password, db=self.database, cursorclass=MySQLdb.cursors.DictCursor, cp_reconnect=True)
I would think that this would fix it, and it seemed for a while, but now I see that the "MySQL server has gone away" error again after there is no activity on the server for a while.
I read this MySQL documentation regarding wait_timeout , and I could fix it this way, I suppose, but why does the cp_reconnect function work for me? I interpret adbapi docs to indicate that if you specify the cp_reconnect parameter, adbadpi will handle the error sent by MySQL, and try the query again for you. So basically you do not need to handle the error directly in your code. I dont understand what?
source share