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
This commit is contained in:
parent
220c3d6d78
commit
efc876585e
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user