[Twisted-Python] Consensus on how to handle "MySQL server has gone away"

E S electric.or.sharp at gmail.com
Tue Oct 2 13:09:29 EDT 2012


I have a service running that occasionally connects to a MySQL
database. When there is no activity on it for some time, I eventually
get the the error

_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')

I have found a few posts on this group related to this issue

http://twistedmatrix.com/pipermail/twisted-python/2007-July/015788.html
http://twistedmatrix.com/pipermail/twisted-python/2007-October/016178.html

as well as some tickets on the twisted homepage:

http://twistedmatrix.com/trac/ticket/4404
http://twistedmatrix.com/trac/ticket/4964

I have also seen this referenced as a potential fix:

http://www.gelens.org/2009/09/13/twisted-connectionpool-revisited/

I currently have the cp_reconnect parameter set to True, but it does
not appear to be doing the job. I don't really see much consensus on
how to properly handle this issue. Some people seem to think that the
cp_reconnect parameter should take care of it for you, other people
say that cp_reconnect is only part of the solution and that you have
to write your own error handling.

I realize that I could increase the value of MySQL's wait_timeout
parameter, but I would rather have the twisted code detect and handle
the situation. So, how does one do that?

Thanks,
Dave



More information about the Twisted-Python mailing list