MySQLConnection.disconnect() fails on dead connection

Bug #752975 reported by tormen on 2011-04-06
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Geert JM Vanderkelen

Bug Description

MySQL Connector/Python version 0.3.2 with Python 3.2:

Within class MySQLConnection:

.connect() calls .disconnect() triggers a signal 13 if the connection is dead!
--> put a try: self.disconnect()
except: pass
in .connect() and .connect() works as the .reconnect() I wanted ... except that
my reconnect will check is_connected AND have a semaphore around the .connect()
call to avoid race conditions between multiple cursors :)

... and actually looking at .disconnect() the signal 13 originates from the call
If I move this line into the try block you already have in .disconnect, the
signal 13 does not happen and the try, except around the .disconnect() call
within .connect() are not necessary.

Side note: The patch also fixes a wrong indentation:
Line 453 in
self.collation = collation
def _post_connection(self, time_zone=None, autocommit=False,
shows invalid indenting in my eclipse.

tormen (quickhelp) wrote :
tormen (quickhelp) wrote :


Thanks for reporting this bug!
I'm trying to reproduce this. If I understand the problem, if you kill the connection, you would get an error, right?
Something like this:

    cnx = mysql.connector.connect(user='root')

Could you get a small test case like the above?


Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
status: New → Incomplete
Changed in myconnpy:
status: Incomplete → Confirmed
importance: Undecided → Medium

The code around MySQLConnection.connect() has been refactored, but there might be still some improvement needed.
We'll check a bit more if handling the exceptions is now done correctly.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers