-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CC-5840: Add Media -> Endless retries if there is a validation error
Fixed by not adding message to retry queue if request returns a validation specific error code (422)
- Loading branch information
Showing
2 changed files
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,9 +91,13 @@ def send_http_request(picklable_request, retry_queue): | |
r.raise_for_status() # Raise an exception if there was an http error code returned | ||
logging.info("HTTP request sent successfully.") | ||
except requests.exceptions.RequestException as e: | ||
This comment has been minimized.
Sorry, something went wrong. |
||
# If the web server is having problems, retry the request later: | ||
logging.error("HTTP request failed. Retrying later! Exception was: %s" % str(e)) | ||
retry_queue.append(picklable_request) | ||
if r.status_code != 422: | ||
This comment has been minimized.
Sorry, something went wrong.
asantoni
Contributor
|
||
# If the web server is having problems, retry the request later: | ||
logging.error("HTTP request failed. Retrying later! Exception was: %s" % str(e)) | ||
retry_queue.append(picklable_request) | ||
else: | ||
# Do no retry the request if there was a metadata validation error | ||
logging.error("HTTP request failed. Exception was: %s" % str(e)) | ||
except Exception as e: | ||
logging.error("HTTP request failed with unhandled exception. %s" % str(e)) | ||
# Don't put the request into the retry queue, just give up on this one. | ||
|
Also, I made a mistake here with this general RequestException handler. Only HTTPErrors give us a status code. ConnectionErrors won't, so I've handled HTTPErrors explicitly now.