feat(675): Add retry strategy support for all API calls made to Facebook. #691
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #675, there are occasions where an API call will fail due to server-side issues. It's common practice to retry API calls when they're safe, e.g., GET or POST-type calls with idempotency. Also if too many requests are being made and a 429 is being raised, we want to re-send the request again in a safe manner at the correct time, according to any HTTP headers.
So, adding in a Retry strategy that works well with the FacebookSession class and is written in a consistent form to other features you can specify, like API_VERSION or Timeout.
To make it easier for end users to use this feature, there is a default Retry strategy that can be toggled on via the Ads App Config settings. This default strategy is also partially customisable. Finally, advanced users can specify their own Retry strategy from scratch, but all require the Retry class from urllib3.