-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upload: add connection exceptions to upload retry protocol #1031
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,21 +183,31 @@ def upload( | |
) -> requests.Response: | ||
number_of_redirects = 0 | ||
while number_of_redirects < max_redirects: | ||
resp = self._upload(package) | ||
|
||
if resp.status_code == requests.codes.OK: | ||
return resp | ||
if 500 <= resp.status_code < 600: | ||
try: | ||
resp = self._upload(package) | ||
except ( | ||
requests.exceptions.ConnectionError, | ||
requests.exceptions.ConnectTimeout, | ||
) as exc: | ||
number_of_redirects += 1 | ||
logger.warning( | ||
f'Received "{resp.status_code}: {resp.reason}"' | ||
f"{exc.__class__.__name__} raised." | ||
"\nPackage upload appears to have failed." | ||
f" Retry {number_of_redirects} of {max_redirects}." | ||
) | ||
continue | ||
else: | ||
return resp | ||
|
||
return resp | ||
if resp.status_code == requests.codes.OK: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slighlty redundant, but can leave for clarity. Should add a continue to the retry if clause. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, as the _upload function calls on POST without redirects, we aren't really handling anywhere (they are simply returned) |
||
return resp | ||
if 500 <= resp.status_code < 600: | ||
number_of_redirects += 1 | ||
logger.warning( | ||
f'Received "{resp.status_code}: {resp.reason}"' | ||
"\nPackage upload appears to have failed." | ||
f" Retry {number_of_redirects} of {max_redirects}." | ||
) | ||
else: | ||
return resp | ||
|
||
def package_is_uploaded( | ||
self, package: package_file.PackageFile, bypass_cache: bool = False | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I rename to retries? redirects aren't really handled here.