diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-08 03:27:09 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-08 03:27:09 +0000 |
| commit | c6538b6b3400cbfa939d4e3e8d0f0530e0530e9d (patch) | |
| tree | e9d9713d8b437a425ea0bed1ccc33c2b62cff0e5 /lib/sqlalchemy/pool.py | |
| parent | 21d4e2a96eb8f505e8d2c942204917477c4323d3 (diff) | |
| download | sqlalchemy-c6538b6b3400cbfa939d4e3e8d0f0530e0530e9d.tar.gz | |
- MySQL detects errors 2006 (server has gone away) and 2014
(commands out of sync) and invalidates the connection on which it occured.
Diffstat (limited to 'lib/sqlalchemy/pool.py')
| -rw-r--r-- | lib/sqlalchemy/pool.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 99504e136..8e74f0343 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -187,7 +187,7 @@ class _ConnectionFairy(object): """proxies a DBAPI connection object and provides return-on-dereference support""" def __init__(self, pool): self._threadfairy = _ThreadFairy(self) - self.cursors = weakref.WeakKeyDictionary() + self.cursors = {} self.__pool = pool self.__counter = 0 try: @@ -220,8 +220,9 @@ class _ConnectionFairy(object): self.__counter +=1 return self def close_open_cursors(self): - for c in list(self.cursors): - c.close() + if self.cursors is not None: + for c in list(self.cursors): + c.close() def close(self): self.__counter -=1 if self.__counter == 0: @@ -255,13 +256,15 @@ class _CursorFairy(object): self.__parent = parent self.__parent.cursors[self]=True self.cursor = cursor + def invalidate(self): + self.__parent.invalidate() def close(self): if self in self.__parent.cursors: del self.__parent.cursors[self] self.cursor.close() def __getattr__(self, key): return getattr(self.cursor, key) - + class SingletonThreadPool(Pool): """Maintains one connection per each thread, never moving a connection to a thread other than the one which it was created in. |
