diff --git a/deker_server_adapters/factory.py b/deker_server_adapters/factory.py index 1b89170..89fdd10 100644 --- a/deker_server_adapters/factory.py +++ b/deker_server_adapters/factory.py @@ -23,15 +23,15 @@ class AdaptersFactory(BaseAdaptersFactory): def __init__(self, ctx: "CTX", uri: "Uri") -> None: # Make base url, so all urls will be relative kwargs = { - "base_url": uri.raw_url, - "verify": True, - "http2": False, - "timeout": None, + # "base_url": uri.raw_url, + # "verify": True, + # "http2": False, + # "timeout": None, } # If Uri contains auth params, remember them - if uri.username: - kwargs.update({"auth": (uri.username, uri.password)}) + # if uri.username: + # kwargs.update({"auth": (uri.username, uri.password)}) # update values from context kwargs kwargs.update(ctx.extra.get("httpx_conf", {})) @@ -47,6 +47,8 @@ def __init__(self, ctx: "CTX", uri: "Uri") -> None: ) self.httpx_client = HttpxClient(**kwargs) + self.httpx_client.base_url = uri.raw_url + self.httpx_client.auth = (uri.username, uri.password) # We have to keep reference to ctx, to be able to set new configuration self.httpx_client.ctx = copied_ctx copied_ctx.extra["httpx_client"] = self.httpx_client diff --git a/deker_server_adapters/httpx_client.py b/deker_server_adapters/httpx_client.py index bc9b483..dd9f04a 100644 --- a/deker_server_adapters/httpx_client.py +++ b/deker_server_adapters/httpx_client.py @@ -3,6 +3,7 @@ from deker.ctx import CTX from deker.errors import DekerMemoryError from httpx import Client, Response +from requests import Session from deker_server_adapters.cluster_config import apply_config from deker_server_adapters.consts import ( @@ -44,7 +45,7 @@ def rate_limit_err(response: Response, message: str, class_: Type[DekerBaseRateL ) -class HttpxClient(Client): +class HttpxClient(Session): """Wrapper around HttpxClient.""" ctx: CTX @@ -57,6 +58,7 @@ def request(self, *args: Any, retry_on_hash_failure: bool = False, **kwargs: Any :param retry_on_hash_failure: If we should retry on invalid hash :param kwargs: keyword arguments to request """ + kwargs["timeout"] = None response = super().request(*args, **kwargs) if response.status_code == CONFLICT_HASH: apply_config(response.json(), self.ctx) diff --git a/poetry.lock b/poetry.lock index 1647daa..268d639 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1594,13 +1594,13 @@ files = [ [[package]] name = "requests" -version = "2.31.0" +version = "2.32.3" description = "Python HTTP for Humans." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "requests-2.31.0-py3-none-any.whl", hash = "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f"}, - {file = "requests-2.31.0.tar.gz", hash = "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -2273,4 +2273,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "ebac2913a68fde5b0f6e3e04ef491d9b089ec7ffa217a861fd5fc3049c7f58aa" +content-hash = "16465440eda3ffc7aa808e863003597ea7c39b92277a30d872d36e251ff5dd63" diff --git a/pyproject.toml b/pyproject.toml index 7074d1b..e628937 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ priority = "supplemental" python = "^3.9" httpx = "^0.27.0" pytest-httpx = "^0.30.0" +requests = "^2.32.3" [tool.poetry.group.dev.dependencies] black = "^23.7.0"