From efc876585e56090685914893e092b81ba4bbd86e Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Wed, 31 Mar 2021 12:36:13 +0200 Subject: [PATCH] Avoid PyPI ratelimit on roles retrieval retry When validating PyPI settings, we retrieve package roles. If that retrieval is not successful on the first try, we immediately retry with a canonicalized version of the package. This sometimes hits PyPI ratelimits. This patch introduces a one second sleep to avoid that error. Change-Id: Ifd20200159a2f136827a1987606b650a6db5588f --- openstack_releases/pythonutils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openstack_releases/pythonutils.py b/openstack_releases/pythonutils.py index 48cd6b8df9..9764cd7024 100644 --- a/openstack_releases/pythonutils.py +++ b/openstack_releases/pythonutils.py @@ -16,6 +16,7 @@ import json import logging import os import os.path +import time import xmlrpc.client from packaging import utils as packaging_utils @@ -144,6 +145,9 @@ def _get_pypi_roles(dist_name): def get_pypi_uploaders(dist_name): roles = _get_pypi_roles(dist_name) if not roles: + # Sleep one second before retrying, to avoid PyPI returning + # TooManyRequests and hiding the real issue + time.sleep(1) canonical_name = packaging_utils.canonicalize_name(dist_name) roles = _get_pypi_roles(canonical_name) uploaders = set(