From 6f16b8db6f08cefd68cdf251292316497eb849b3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 9 Feb 2011 15:06:32 -0500 Subject: - add connection and cursor to is_disconnect(). We aren't using it yet, but we'd like to. Most DBAPIs don't give us anything we can do with it. Some research was done on psycopg2 and it still seems like they give us no adequate method (tried connection.closed, cursor.closed, connection.status). mxodbc claims their .closed attribute will work (but I am skeptical). - remove beahvior in pool that auto-invalidated a connection when the cursor failed to create. That's not the pool's job. we need the conn for the error logic. Can't get any tests to fail, curious why that behavior was there, guess we'll find out (or not). - add support for psycopg2 version detection. even though we have no use for it yet... - adjust one of the reconnect tests to work with oracle's horrendously slow connect speed --- lib/sqlalchemy/engine/base.py | 4 ++-- lib/sqlalchemy/engine/default.py | 2 +- 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 b78a30537..f6c974136 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -502,7 +502,7 @@ class Dialect(object): raise NotImplementedError() - def is_disconnect(self, e): + def is_disconnect(self, e, connection, cursor): """Return True if the given DB-API error indicates an invalid connection""" @@ -1518,7 +1518,7 @@ class Connection(Connectable): if context: context.handle_dbapi_exception(e) - is_disconnect = self.dialect.is_disconnect(e) + is_disconnect = self.dialect.is_disconnect(e, self.__connection, cursor) if is_disconnect: self.invalidate(e) self.engine.dispose() diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index aa75a2853..e669b305e 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -324,7 +324,7 @@ class DefaultDialect(base.Dialect): def do_execute(self, cursor, statement, parameters, context=None): cursor.execute(statement, parameters) - def is_disconnect(self, e): + def is_disconnect(self, e, connection, cursor): return False def reset_isolation_level(self, dbapi_conn): -- cgit v1.2.1