#14 Fix Retry allowed methods for urllib 1.25
Opened 7 months ago by adamwill. Modified 7 months ago
taskotron/ adamwill/resultsdb_api fix-retry-allow  into  develop

file modified
+7 -2
@@ -128,12 +128,17 @@ 

          self.auth_token = auth_token

          self.request_auth = request_auth

  

-         allowed_methods = list(Retry.DEFAULT_ALLOWED_METHODS) + ["POST"]

+         if hasattr(Retry, "DEFAULT_ALLOWED_METHODS"):

+             allowed_methods = list(Retry.DEFAULT_ALLOWED_METHODS) + ["POST"]

+             _allow_args = {"allowed_methods": allowed_methods}

+         else:

+             allowed_methods = list(Retry.DEFAULT_METHOD_WHITELIST) + ["POST"]

+             _allow_args = {"method_whitelist": allowed_methods}

          self._retry = Retry(

                  total=max_retries,

                  backoff_factor=backoff_factor,

                  status_forcelist=(500, 502, 503, 504),

-                 allowed_methods=allowed_methods

+                 **_allow_args

                  )

          self._adapter = HTTPAdapter(max_retries=self._retry)

          self.session = _ResultsDBSession()

This is a follow-up to ae4a3a6. It seems urllib devs went with a
really aggressive deprecation schedule here - the kwarg
name they deprecated in 1.26 does not exist in 1.25, which is
still shipped in Fedora 34 (and probably many other stable
distros). If you want the code to work on both 1.25 and 1.26
without any deprecation warnings, you need to fudge it like
this. Inspired by
https://github.com/firebase/firebase-admin-python/pull/532 .

Signed-off-by: Adam Williamson awilliam@redhat.com

rebased onto e6d0c2c

7 months ago
Metadata