summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-10-14 15:55:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-10-14 19:17:40 -0400
commit92c20be2c244c98735cdf91d747a9227b58b9854 (patch)
treed3eaeb23e494fff23d94afb25c8891a1da8ccda8
parented735af55d2c863cbe7cfde7b4ef3a9cda7c0733 (diff)
downloadsqlalchemy-92c20be2c244c98735cdf91d747a9227b58b9854.tar.gz
Don't call rollback on DBAPI connection that's "closed"
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 (cherry picked from commit a8781b51b4039eee56791b9dbfdee183f7a5b797)
-rw-r--r--lib/sqlalchemy/testing/engines.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py
index f452a3e2f..f963ba8b2 100644
--- a/lib/sqlalchemy/testing/engines.py
+++ b/lib/sqlalchemy/testing/engines.py
@@ -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):