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.
Pull Request description
This PR aims to implement a exponential backoff. pymedx fetch data from a remote server (PubMed). This operation can fail for a myriad of reasons – network issues, server overload, brief disruptions in service, etc. If the application simply gives up after the first failure, it risks missing out on the opportunity to succeed in a subsequent attempt.
This is where retrying comes in as a basic yet crucial mechanism. So in other words If the first attempt did not succeed pymedx will wait for 2 seconds, if the second attempt fail pymedx will wait for 4 seconds and so on, the sequence in waiting times is 0 2 4 8 16 32 32 32 32 (seconds). Notice that is caped at 32 seconds
I added a jitter as well which is added to backoff_time and is a float number between 0 and 1. The addition of a random “jitter” avoids the scenario where many clients, following the same exponential backoff algorithm, retry simultaneously.
Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
complexity.
Additional information
Reviewer's checklist
Copy and paste this template for your review's note: