diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-11 23:15:32 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-11 23:15:32 +0000 |
commit | 2d8b5bb4f36e5624f25b170391fe42d3bfbeb623 (patch) | |
tree | a6267f998e2c54ef3d1405d23bd3a6a1618280ef /lib/sqlalchemy/pool.py | |
parent | 2fbeeb125c83664d684cfabdfa8548d518e758a6 (diff) | |
download | sqlalchemy-2d8b5bb4f36e5624f25b170391fe42d3bfbeb623.tar.gz |
Added an exception hierarchy shadowing DB-API exc types
No more generic SQLErrors wrappers- the shadow type matching the DB-API error is raised. [ticket:706]
SQLError is now (also) DBAPIError.
DBAPIError and subtype constructors will refuse to wrap a SystemExit or KeyboardInterrupt, returningthe original interrupt exception instead of a new instance. [ticket:689]
Added a passthroughs for SE/KI exceptions in a couple except-and-discard situations
Diffstat (limited to 'lib/sqlalchemy/pool.py')
-rw-r--r-- | lib/sqlalchemy/pool.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index f6965495f..526abe81c 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -241,6 +241,8 @@ class _ConnectionRecord(object): self.connection.close() except Exception, e: self.__pool.log("Connection %s threw an error on close: %s" % (repr(self.connection), str(e))) + if isinstance(e, (SystemExit, KeyboardInterrupt)): + raise def __connect(self): try: @@ -371,6 +373,8 @@ class _ConnectionFairy(object): except Exception, e: if self._connection_record is not None: self._connection_record.invalidate(e=e) + if isinstance(e, (SystemExit, KeyboardInterrupt)): + raise if self._connection_record is not None: if self._pool.echo: self._pool.log("Connection %s being returned to pool" % repr(self.connection)) @@ -394,6 +398,8 @@ class _CursorFairy(object): self.cursor.close() except Exception, e: self.__parent._logger.warn("Error closing cursor: " + str(e)) + if isinstance(e, (SystemExit, KeyboardInterrupt)): + raise def __getattr__(self, key): return getattr(self.cursor, key) @@ -432,8 +438,11 @@ class SingletonThreadPool(Pool): for key, conn in self._conns.items(): try: conn.close() + except (SystemExit, KeyboardInterrupt): + raise except: - # sqlite won't even let you close a conn from a thread that didn't create it + # sqlite won't even let you close a conn from a thread + # that didn't create it pass del self._conns[key] |