Commits

Anonymous committed 6fffa8f

todo & fix eventlet

Comments (0)

Files changed (3)

restkit/ext/eventlet_pool.py

         return make_connection(self.uri, self.use_proxy)
            
     def put(self, connection):
-        try:
-            connection.close()
-        except:
-            pass
-        Pool.put(self, make_connection(self.uri, self.use_proxy))
+        Pool.put(self, self.create())
         else:
             pool = self.connections[conn_key] = self.pool_class(uri, self.use_proxy)
         connection = pool.get()
-        
-        if connection.sock is False:
-            connection.connect()
-            
         return connection
         
     def _release_connection(self, uri, connection):
 
 """
 Threadsafe Pool class based on eventlet.pools.Pool but using Queue.Queue
+
+TODO:
+- add our own way to share socket across connections. We shouldn't need to rely
+  on eventlet for that
+- log errors
 """
 
-# TODO: log error
+
 
 import collections
 import httplib
     def waiting(self):
         """Return the number of routines waiting for a pool item.
         """
-        return max(0, self.max_size - self.channel.qsize())
+        return self.channel.qsize() <= self.max_size
     
     def create(self):
         """Generate a new pool item
         """
         raise NotImplementedError("Implement in subclass")
-        
-        
+                
 class ConnectionPool(Pool):
     def __init__(self, uri, use_proxy=False, min_size=0, max_size=4):
         self.uri = uri
             self.current_size -= 1
             self.lock.release()
             return
-
+        
         Pool.put(self, self.create())