]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Don't call rollback on DBAPI connection that's "closed"
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Oct 2018 19:55:46 +0000 (15:55 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Oct 2018 19:55:46 +0000 (15:55 -0400)
Use the existence of ConnectionRecord.connection to estimate
that this connection is likely closed, and if so, don't
try to call "rollback" on it.  This rollback is normally harmless
but is causing segfaults in mysqlclient due to
https://github.com/PyMySQL/mysqlclient-python/issues/270.

Change-Id: I1d7c5f5a520527d8268b6334795c2051f7ceeea6

lib/sqlalchemy/testing/engines.py

index 7404befb83f8b29ebe17caf64c9c1d47092855a3..d17e30edff398edf749a4c1c4a5f41acd8120824 100644 (file)
@@ -59,6 +59,12 @@ class ConnectionKiller(object):
         # not sure if this should be if pypy/jython only.
         # note that firebird/fdb definitely needs this though
         for conn, rec in list(self.conns):
+            if rec.connection is None:
+                # this is a hint that the connection is closed, which
+                # is causing segfaults on mysqlclient due to
+                # https://github.com/PyMySQL/mysqlclient-python/issues/270;
+                # try to work around here
+                continue
             self._safe(conn.rollback)
 
     def _stop_test_ctx(self):