]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixed endless loop thing
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 23 Oct 2005 17:01:47 +0000 (17:01 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 23 Oct 2005 17:01:47 +0000 (17:01 +0000)
lib/sqlalchemy/pool.py

index d181f39c3023081496dd892c0087535135e79e48..023220ac2f8523203870c52447cc5ef66736e49f 100644 (file)
@@ -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):