Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions requests_unixsocket/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def connect(self):

class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):

def __init__(self, socket_path, timeout=60):
def __init__(self, socket_path, timeout=60, maxsize=1, **kwargs):
super(UnixHTTPConnectionPool, self).__init__(
'localhost', timeout=timeout)
'localhost', timeout=timeout, maxsize=maxsize, **kwargs)
self.socket_path = socket_path
self.timeout = timeout

Expand All @@ -51,9 +51,11 @@ def _new_conn(self):

class UnixAdapter(HTTPAdapter):

def __init__(self, timeout=60, pool_connections=25, *args, **kwargs):
def __init__(self, timeout=60, pool_connections=25, pool_maxsize=1,
*args, **kwargs):
super(UnixAdapter, self).__init__(*args, **kwargs)
self.timeout = timeout
self.pool_maxsize = pool_maxsize
self.pools = urllib3._collections.RecentlyUsedContainer(
pool_connections, dispose_func=lambda p: p.close()
)
Expand All @@ -75,7 +77,7 @@ def get_connection(self, url, proxies=None):
if pool:
return pool

pool = UnixHTTPConnectionPool(url, self.timeout)
pool = UnixHTTPConnectionPool(url, self.timeout, maxsize=self.pool_maxsize)
self.pools[url] = pool

return pool
Expand Down
Loading