Skip to content

Commit

Permalink
Merge pull request #376 from DataDog/shubho/add-429-response-code
Browse files Browse the repository at this point in the history
Handle http code 429 for rate limiting
  • Loading branch information
ssc3 authored May 14, 2019
2 parents 85b7e46 + dc2ef1d commit 9935422
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datadog/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ApiError(Exception):
"""
Datadog returned an API error (known HTTPError).
Matches the following status codes: 400, 403, 404, 409.
Matches the following status codes: 400, 403, 404, 409, 429.
"""


Expand Down
4 changes: 2 additions & 2 deletions datadog/api/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def request(cls, method, url, headers, params, data, timeout, proxies, verify, m
except requests.exceptions.Timeout:
raise _remove_context(HttpTimeout(method, url, timeout))
except requests.exceptions.HTTPError as e:
if e.response.status_code in (400, 403, 404, 409):
if e.response.status_code in (400, 403, 404, 409, 429):
# This gets caught afterwards and raises an ApiError exception
pass
else:
Expand Down Expand Up @@ -156,7 +156,7 @@ def raise_on_status(cls, result):
status_code = result.status_code

if (status_code / 100) != 2:
if status_code in (400, 403, 404, 409):
if status_code in (400, 403, 404, 409, 429):
pass
else:
raise HTTPError(status_code)
Expand Down

0 comments on commit 9935422

Please sign in to comment.