1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-11 07:06:16 +01:00

Merge pull request #1260 from dmach/connection-retry-backoff_factor

connection: Wait between retries
This commit is contained in:
Daniel Mach 2023-02-09 13:27:57 +01:00 committed by GitHub
commit 7fec5c8c25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import base64 import base64
import fcntl import fcntl
import inspect
import os import os
import re import re
import shutil 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) pool = CONNECTION_POOLS.get(apiurl, None)
if not pool: if not pool:
pool_kwargs = {} pool_kwargs = {}
pool_kwargs["retries"] = urllib3.Retry(total=int(conf.config["http_retries"]))
# 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": if purl.scheme == "https":
ssl_context = oscssl.create_ssl_context() ssl_context = oscssl.create_ssl_context()