From 814637e291953bc7e05ced3e215ef33bde5b040a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 30 May 2014 16:24:38 -0400 Subject: - vastly improve the "safe close cursor" tests in test_reconnect - Fixed bug which would occur if a DBAPI exception occurs when the engine first connects and does its initial checks, and the exception is not a disconnect exception, yet the cursor raises an error when we try to close it. In this case the real exception would be quashed as we tried to log the cursor close exception via the connection pool and failed, as we were trying to access the pool's logger in a way that is inappropriate in this very specific scenario. fixes #3063 --- lib/sqlalchemy/engine/base.py | 5 +++-- lib/sqlalchemy/engine/strategies.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/engine') diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index f9fc04d76..249c494fe 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1054,8 +1054,9 @@ class Connection(Connectable): except (SystemExit, KeyboardInterrupt): raise except Exception: - self.connection._logger.error( - "Error closing cursor", exc_info=True) + # log the error through the connection pool's logger. + self.engine.pool.logger.error( + "Error closing cursor", exc_info=True) _reentrant_error = False _is_disconnect = False diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py index a8a63bb3d..691c06a8c 100644 --- a/lib/sqlalchemy/engine/strategies.py +++ b/lib/sqlalchemy/engine/strategies.py @@ -161,7 +161,6 @@ class DefaultEngineStrategy(EngineStrategy): def first_connect(dbapi_connection, connection_record): c = base.Connection(engine, connection=dbapi_connection, _has_events=False) - dialect.initialize(c) event.listen(pool, 'first_connect', first_connect, once=True) -- cgit v1.2.1