[Twisted-Python] "MySQL has gone away"

马踏飞燕 honeyday.mj at gmail.com
Thu Jul 26 21:48:12 EDT 2007

2007/7/26, Pavel Bastov <pbastov at gmail.com>:
> Hi all,
> I'm using MySQL database in my server app. Pretty often after some
> inactivity I get this message in my logs "MySQL server has gone away".
> How can I prevent this?

U can use Mysql::Ping(dbh) to keep the connection alive.

n = mysql::Ping(dbh)

Checks whether or not the connection to the server is working. If it
has gone down, an automatic reconnection is attempted.

Clients that remain idle for a long while, to check whether or not the
server has closed the connection and reconnect if necessary can use
this function.

Returns true if the server is alive and false if an error occurred.

More information about the Twisted-Python mailing list