Skip to content

Commit

Permalink
feat(api)!: remove timeout code
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove timeout code and `timeout` parameter from method
signatures, because it gives the impression of doing something, but
seems to be ineffective (see
#44).
  • Loading branch information
msabramo committed Dec 27, 2021
1 parent 8449bc0 commit 0421f81
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions requests_unixsocket/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
# https://github.com/docker/docker-py/blob/master/docker/transport/unixconn.py
class UnixHTTPConnection(httplib.HTTPConnection, object):

def __init__(self, unix_socket_url, timeout=60):
def __init__(self, unix_socket_url):
"""Create an HTTP connection to a unix domain socket
:param unix_socket_url: A URL with a scheme of 'http+unix' and the
netloc is a percent-encoded path to a unix domain socket. E.g.:
'http+unix://%2Ftmp%2Fprofilesvc.sock/status/pid'
"""
super(UnixHTTPConnection, self).__init__('localhost', timeout=timeout)
super(UnixHTTPConnection, self).__init__('localhost')
self.unix_socket_url = unix_socket_url
self.timeout = timeout
self.sock = None

def __del__(self): # base class does not have d'tor
Expand All @@ -44,21 +43,18 @@ def connect(self):

class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):

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

def _new_conn(self):
return UnixHTTPConnection(self.socket_path, self.timeout)
return UnixHTTPConnection(self.socket_path)


class UnixAdapter(HTTPAdapter):

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

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

return pool
Expand Down

0 comments on commit 0421f81

Please sign in to comment.