From 2f6b50ec2b09dcf744f8b3e42bd85eec97d9a2a6 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Thu, 9 Feb 2023 09:32:25 +0100 Subject: [PATCH 1/2] connection: Wait between retries --- osc/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osc/connection.py b/osc/connection.py index a6441211..26b2b498 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -217,7 +217,7 @@ def http_request(method: str, url: str, headers=None, data=None, file=None): pool = CONNECTION_POOLS.get(apiurl, None) if not pool: pool_kwargs = {} - pool_kwargs["retries"] = urllib3.Retry(total=int(conf.config["http_retries"])) + pool_kwargs["retries"] = urllib3.Retry(total=int(conf.config["http_retries"]), backoff_factor=2) if purl.scheme == "https": ssl_context = oscssl.create_ssl_context() From 05d381ad798adf0662076214cc6b8cdd1c1c0275 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Thu, 9 Feb 2023 13:00:55 +0100 Subject: [PATCH 2/2] connection: Retry all, not just default allowed methods --- osc/connection.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osc/connection.py b/osc/connection.py index 26b2b498..630b7892 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -1,5 +1,6 @@ import base64 import fcntl +import inspect import os import re import shutil @@ -217,7 +218,20 @@ def http_request(method: str, url: str, headers=None, data=None, file=None): pool = CONNECTION_POOLS.get(apiurl, None) if not pool: pool_kwargs = {} - pool_kwargs["retries"] = urllib3.Retry(total=int(conf.config["http_retries"]), backoff_factor=2) + + # urllib3.Retry() argument 'method_whitelist' got renamed to 'allowed_methods' + sig = inspect.signature(urllib3.Retry) + arg_names = list(sig.parameters.keys()) + if "allowed_methods" in arg_names: + retries_kwargs = {"allowed_methods": None} + else: + retries_kwargs = {"method_whitelist": None} + + pool_kwargs["retries"] = urllib3.Retry( + total=int(conf.config["http_retries"]), + backoff_factor=2, + **retries_kwargs, + ) if purl.scheme == "https": ssl_context = oscssl.create_ssl_context()