I have a module in my Django 1.6 app (Python3) that runs like a daemon but it's throwing this error after a couple of hours running:
OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))")
It seems that exist a flag in MySQL connection that autoreconnect called MYSQL_OPT_RECONNECT, should I set it? Where? I’m using PyMySQL connector (by running pymysql.install_as_MySQLdb() in the main __init__.py).
We have to catch the error when it is thrown, and call
django.db.connection.close()to reconnect.I did not found a way to make it automatic, though, but it did the job.