[Twisted-Python] "MySQL has gone away"

Phil Christensen phil at bubblehouse.org
Thu Jul 26 10:17:55 EDT 2007

On Jul 26, 2007, at 6:11 AM, Pavel Bastov wrote:

> 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?

I've seen this most frequently when I'm dealing with the MySQLdb  
module directly (i.e., not using twisted.adbapi).

It was happening to me when I was trying to use a single cursor  
throughout my code by passing it around as a property of some object.

I believe it has something to do with the weak references used  
internally in the MySQLdb module (this is just a theory).

My solution was to fetch a new cursor in each scope where I needed  
it, making sure to close it when I was done.

Just my 2/100ths....


More information about the Twisted-Python mailing list