Commits

Anonymous committed 32262fe

some fixes

  • Participants
  • Parent commits 40be280

Comments (0)

Files changed (3)

File restkit/__init__.py

 
 
 try:
-    __version__ = __import__('pkg_resources').get_distribution('py-restkit').version
+    __version__ = __import__('pkg_resources').get_distribution('restkit').version
 except:
     __version__ = '?'
 

File restkit/pool.py

 
 import collections
 import httplib
-from Queue import Queue, Full, Empty
+import Queue
 import threading
 
 from restkit import errors
         self.max_size = max_size
         self.order_as_stack = order_as_stack
         self.current_size = 0
-        self.channel = Queue(0)
+        self.channel = Queue.Queue(0)
         self.free_items = collections.deque()
         for x in xrange(min_size):
             self.current_size += 1
     def do_get(self):
         """
         Return an item from the pool, when one is available
-        """
+        """ 
         self.lock.acquire()
         try:
             if self.free_items:
                 created = self.create()
                 self.current_size += 1
                 return created
+                
             try:
                 return self.channel.get(False)
-            except Empty:
-                return self.create()
+            except Queue.Empty:
+                created = self.create()
+                self.current_size += 1
+                return created
+                
         finally:
             self.lock.release()
 

File restkit/rest.py

         """
         obj = self.__class__(self.uri, transport=self.transport, headers=self._headers,
                 follow_redirect=self.follow_redirect, force_follow_redirect=self.force_follow_redirect, 
-                use_proxy=self.use_proxy, min_size=self.min_size, max_size=self.max_size)
+                use_proxy=self.use_proxy, min_size=self.min_size, max_size=self.max_size, 
+                pool_class=self.pool_class)
         return obj
    
     def __call__(self, path):
                 _headers['Content-Type'] = type_ and type_ or 'application/octet-stream'
                 
                 
-        def _try_request(retry=1):
-            try:
-                return self.transport.request(self.make_uri(uri, path, **params), 
-                            method=method, body=body, headers=_headers, 
-                            stream=_stream, stream_size=_stream_size)
-            except (socket.error, httplib.BadStatusLine), e:
-                if retry > 0:
-                    time.sleep(0.4)
-                return _try_request(retry-1)
-            except Exception, e:
-                RequestError(str(e))
         
-        resp, data = _try_request()
+        resp, data = self.transport.request(self.make_uri(uri, path, **params), 
+                        method=method, body=body, headers=_headers, 
+                        stream=_stream, stream_size=_stream_size)
         self.status  = status_code = resp.status
         self.response = resp