Commit 161bb56d by Simon Chen

Add 104 to be part of the retry error ECOM-7042

parent e7ab02da
...@@ -210,8 +210,9 @@ def can_retry_sailthru_request(error): ...@@ -210,8 +210,9 @@ def can_retry_sailthru_request(error):
""" Returns True if a Sailthru request and be re-submitted after an error has occurred. """ Returns True if a Sailthru request and be re-submitted after an error has occurred.
Responses with the following codes can be retried: Responses with the following codes can be retried:
9: Internal Error 9: Internal Error
43: Too many [type] requests this minute to /[endpoint] API 43: Too many [type] requests this minute to /[endpoint] API
104: Connection reset by peer
All other errors are considered failures, that should not be retried. A complete list of error codes is available at All other errors are considered failures, that should not be retried. A complete list of error codes is available at
https://getstarted.sailthru.com/new-for-developers-overview/api/api-response-errors/. https://getstarted.sailthru.com/new-for-developers-overview/api/api-response-errors/.
...@@ -223,7 +224,7 @@ def can_retry_sailthru_request(error): ...@@ -223,7 +224,7 @@ def can_retry_sailthru_request(error):
bool: Indicates if the original request can be retried. bool: Indicates if the original request can be retried.
""" """
code = error.get_error_code() code = error.get_error_code()
return code in (9, 43) return code in (9, 43, 104)
@shared_task(bind=True, ignore_result=True) @shared_task(bind=True, ignore_result=True)
......
...@@ -559,6 +559,12 @@ class SailthruTests(TestCase): ...@@ -559,6 +559,12 @@ class SailthruTests(TestCase):
self.assertFalse(_update_unenrolled_list(mock_sailthru_client, TEST_EMAIL, self.assertFalse(_update_unenrolled_list(mock_sailthru_client, TEST_EMAIL,
self.course_url, False)) self.course_url, False))
mock_sailthru_client.reset_mock()
# simulate retryable error
mock_sailthru_client.api_get.return_value = MockSailthruResponse({}, error='Connection reset by peer', code=104)
self.assertFalse(_update_unenrolled_list(mock_sailthru_client, TEST_EMAIL,
self.course_url, False))
# test get error from Sailthru # test get error from Sailthru
mock_sailthru_client.reset_mock() mock_sailthru_client.reset_mock()
# simulate unretryable error # simulate unretryable error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment