Anonymous - 2003-01-24

I'm running a script that imports MySQLdb initially, and then (for some data sets) waits about an hour between accesses to the MySQL server (which is on another machine)

Connections early in the script work fine, and when there is no long pause between accesses to the mysql server (the case with most data sets) the script works fine.

After creating and using every connection object, I .close() it.

However, when, after this long pause, I call

connection = MySQLdb.connect(db... etc.)
c = connection.cursor()
c.execute()

I get the following error

  File "random_gsr_calc.py", line 480, in calculate_and_load_gsrs_using_gene_objs_ordered_by_chr_and_chr_index
    cursor.execute(GLOBAL_gsr_to_chr_region_insert_string)
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 61, in execute
    r = self._query(query)
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 168, in _query
    rowcount = self._BaseCursor__do_query(q)
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 112, in __do_query
    db.query(q)

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

Even if I catch this exception, and try again to create a new "connection" object, the same error is thrown when calling execute on the cursor.

I've tried changing variables on the mysql server to make sure timeouts will be plenty long enough...

I've tried reloading the MySQLdb module using reload() during the try statement

Any suggestions what might be going wrong MUCH appreciated! With my understanding,  I really have no clue where things are going wrong...