allow pool_kwargs to be specified in init_poolmanager
authorBen Bass <benbass@codedstructure.net>
Sun, 18 May 2014 19:24:35 +0000 (20:24 +0100)
committerBen Bass <benbass@codedstructure.net>
Sun, 18 May 2014 19:24:35 +0000 (20:24 +0100)
requests/adapters.py

index 995d8f80a54cbb1acb6db269b8befacf82eb497a..da7d7b11b15c7b2d683f1796fd2d959d96b42fb1 100644 (file)
@@ -101,14 +101,17 @@ class HTTPAdapter(BaseAdapter):
         self.init_poolmanager(self._pool_connections, self._pool_maxsize,
                               block=self._pool_block)
 
-    def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK):
-        """Initializes a urllib3 PoolManager. This method should not be called
-        from user code, and is only exposed for use when subclassing the
+    def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs):
+        """Initializes a urllib3 PoolManager.
+
+        This method should not be called from user code, and is only
+        exposed for use when subclassing the
         :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
         :param connections: The number of urllib3 connection pools to cache.
         :param maxsize: The maximum number of connections to save in the pool.
         :param block: Block when no free connections are available.
+        :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.
         """
         # save these values for pickling
         self._pool_connections = connections
@@ -116,7 +119,7 @@ class HTTPAdapter(BaseAdapter):
         self._pool_block = block
 
         self.poolmanager = PoolManager(num_pools=connections, maxsize=maxsize,
-                                       block=block)
+                                       block=block, **pool_kwargs)
 
     def proxy_manager_for(self, proxy, **proxy_kwargs):
         """Return urllib3 ProxyManager for the given proxy.