source-braintree-native: run synchronous API calls in separate threads #2195
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.
Description:
The Braintree SDK makes synchronous HTTP requests, which was blocking the main thread and preventing separate streams from sending concurrent API calls. Any HTTP requests made by the Braintree SDK are now wrapped in
asyncio.to_thread
, which runs the function in a separate thread. This unblocks the main thread and lets separate streams make concurrent API calls.The
maximum_size
property that indicates how many results are found in a specific date window is now used to throw search limit errors sooner instead of after we iterate through & count up all results.Note: The
disputes
stream cannot use themaximum_size
property because the Braintree SDK returns aPaginatedCollection
instead of aResourceCollection
fordisputes
, andPaginatedCollection
s don't have amaximum_size
property.Workflow steps:
(How does one use this feature, and how has it changed)
Documentation links affected:
(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)
Notes for reviewers:
Tested on a local stack. Confirmed:
This change is