diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-09 16:16:53 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-09 16:16:53 -0400 |
commit | 65f5887e9a824ee1b50592325fd9f6cf6d1639f8 (patch) | |
tree | 177934989d959fef9b15d29182a15e2591c66a41 /lib | |
parent | f65ddee93a7143924b417e1c988802f10d0c7b11 (diff) | |
download | sqlalchemy-65f5887e9a824ee1b50592325fd9f6cf6d1639f8.tar.gz |
Added pool logging for "rollback-on-return" and the less used
"commit-on-return". This is enabled with the rest of pool
"debug" logging.
[ticket:2752]
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/pool.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 0470e9e48..ade1e90ce 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -193,8 +193,8 @@ class Pool(log.Identified): except (SystemExit, KeyboardInterrupt): raise except: - self.logger.debug("Exception closing connection %r", - connection) + self.logger.error("Exception closing connection %r", + connection, exc_info=True) @util.deprecated( 2.7, "Pool.add_listener is deprecated. Use event.listen()") @@ -381,12 +381,22 @@ def _finalize_fairy(connection, connection_record, pool, ref, echo): return if connection is not None: + if connection_record and echo: + pool.logger.debug("Connection %r being returned to pool", + connection) + try: if pool.dispatch.reset: pool.dispatch.reset(connection, connection_record) if pool._reset_on_return is reset_rollback: + if echo: + pool.logger.debug("Connection %s rollback-on-return", + connection) pool._dialect.do_rollback(connection) elif pool._reset_on_return is reset_commit: + if echo: + pool.logger.debug("Conneciton %s commit-on-return", + connection) pool._dialect.do_commit(connection) # Immediately close detached instances if connection_record is None: @@ -399,9 +409,6 @@ def _finalize_fairy(connection, connection_record, pool, ref, echo): if connection_record is not None: connection_record.fairy = None - if echo: - pool.logger.debug("Connection %r being returned to pool", - connection) if connection_record.finalize_callback: connection_record.finalize_callback(connection) del connection_record.finalize_callback @@ -436,7 +443,7 @@ class _ConnectionFairy(object): self._connection_record = None raise if self._echo: - self._pool.logger.debug("Connection %r checked out from pool" % + self._pool.logger.debug("Connection %r checked out from pool", self.connection) @property |