diff options
Diffstat (limited to 'lib/sqlalchemy/exceptions.py')
-rw-r--r-- | lib/sqlalchemy/exceptions.py | 13 |
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), |