summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/exceptions.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-12-19 19:51:46 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-12-19 19:51:46 +0000
commitb9b0aca7575e347dfd62221c9d515decee4c75f6 (patch)
tree2b2723368ef80367c6884016ae9a1486d6107d4c /lib/sqlalchemy/exceptions.py
parente7f30cba786beeb788913b4be88c6c46d73c910d (diff)
downloadsqlalchemy-b9b0aca7575e347dfd62221c9d515decee4c75f6.tar.gz
- auto-reconnect support improved; a Connection can now automatically
reconnect after its underlying connection is invalidated, without needing to connect() again from the engine. This allows an ORM session bound to a single Connection to not need a reconnect. Open transactions on the Connection must be rolled back after an invalidation of the underlying connection else an error is raised. Also fixed bug where disconnect detect was not being called for cursor(), rollback(), or commit().
Diffstat (limited to 'lib/sqlalchemy/exceptions.py')
-rw-r--r--lib/sqlalchemy/exceptions.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/sqlalchemy/exceptions.py b/lib/sqlalchemy/exceptions.py
index 8338bc554..530ce3e3a 100644
--- a/lib/sqlalchemy/exceptions.py
+++ b/lib/sqlalchemy/exceptions.py
@@ -62,7 +62,11 @@ class NoSuchColumnError(KeyError, SQLAlchemyError):
class DisconnectionError(SQLAlchemyError):
- """Raised within ``Pool`` when a disconnect is detected on a raw DB-API connection."""
+ """Raised within ``Pool`` when a disconnect is detected on a raw DB-API connection.
+
+ This error is consumed internally by a connection pool. It can be raised by
+ a ``PoolListener`` so that the host pool forces a disconnect.
+ """
class DBAPIError(SQLAlchemyError):
@@ -84,7 +88,7 @@ class DBAPIError(SQLAlchemyError):
Its type and properties are DB-API implementation specific.
"""
- def instance(cls, statement, params, orig):
+ def instance(cls, statement, params, orig, connection_invalidated=False):
# Don't ever wrap these, just return them directly as if
# DBAPIError didn't exist.
if isinstance(orig, (KeyboardInterrupt, SystemExit)):
@@ -95,10 +99,10 @@ class DBAPIError(SQLAlchemyError):
if name in glob and issubclass(glob[name], DBAPIError):
cls = glob[name]
- return cls(statement, params, orig)
+ return cls(statement, params, orig, connection_invalidated)
instance = classmethod(instance)
- def __init__(self, statement, params, orig):
+ def __init__(self, statement, params, orig, connection_invalidated=False):
try:
text = str(orig)
except (KeyboardInterrupt, SystemExit):
@@ -110,6 +114,7 @@ class DBAPIError(SQLAlchemyError):
self.statement = statement
self.params = params
self.orig = orig
+ self.connection_invalidated = connection_invalidated
def __str__(self):
return ' '.join([SQLAlchemyError.__str__(self),