I am currently running scripts to gather data in cross languages during this process while connected some languages such as no, sl, ro my script fails due to MySQL server has gone away.

OperationalError: (2006, 'MySQL server has gone away')
Sleeping for 19.0 seconds, 2013-03-26 08:25:27
Sleeping for 22.0 seconds, 2013-03-26 08:25:46
Sleeping for 12.0 seconds, 2013-03-26 08:26:09
Sleeping for 5.0 seconds, 2013-03-26 08:26:21

My solution was to put a try except to handle this and reconnect to the server if the exception error code is 2006 but the problem is I have many query that I execute in multiple methods. I think an easy way to do is edit the mysql configure but obviously thats not an option. It doesn't happen all the time. Any suggestion or solutions? I am using python as my coding language. 

Here is a rough idea of my solution:
        except MySQLdb.OperationalError, sqlEx:
            if sqlEx[0] == 2006:
                logging.info("Caught the MySQL Server Gone away exception correctly")
                logging.exception(sqlEx)
                time.sleep(10)
                self.connectServer()
                self.dbCursor.execute(botUserQuery)

Thank You,
--
Anuradha Uduwage (Anu)