From: Mike Bayer Date: Sun, 23 Oct 2005 17:01:47 +0000 (+0000) Subject: fixed endless loop thing X-Git-Tag: rel_0_1_0~459 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d57e4c059bd081325c546359fdabc4aca69f2062;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fixed endless loop thing --- diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index d181f39c30..023220ac2f 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -58,7 +58,9 @@ class Pool(object): try: return self._threadconns[thread.get_ident()] except KeyError: + print "HEY" agent = ConnectionFairy(self) + print "HO" self._threadconns[thread.get_ident()] = agent return agent @@ -74,15 +76,21 @@ class Pool(object): class ConnectionFairy: def __init__(self, pool): self.pool = pool - self.connection = pool.get() + try: + self.connection = pool.get() + except: + self.connection = None + raise def cursor(self): return CursorFairy(self, self.connection.cursor()) def __getattr__(self, key): return getattr(self.connection, key) def __del__(self): - self.pool.return_conn(self.connection) - self.pool = None - self.connection = None + print "LALA" + if self.connection is not None: + self.pool.return_conn(self.connection) + self.pool = None + self.connection = None class CursorFairy: def __init__(self, parent, cursor):