From 0421f8183c764cf476a3da16c735419debf7405f Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 27 Dec 2021 14:12:27 -0800 Subject: [PATCH] feat(api)!: remove timeout code 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 https://github.com/msabramo/requests-unixsocket/issues/44). --- requests_unixsocket/adapters.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/requests_unixsocket/adapters.py b/requests_unixsocket/adapters.py index 83e1400..f0e270a 100644 --- a/requests_unixsocket/adapters.py +++ b/requests_unixsocket/adapters.py @@ -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 @@ -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() ) @@ -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