Skip to content

Commit

Permalink
add jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
EverVino committed May 17, 2024
1 parent 0602c73 commit 8db99db
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pymedx/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""API module for PubMed."""
import datetime
import itertools
import random
import time

from typing import Any, Dict, Iterable, List, Union, cast
Expand Down Expand Up @@ -169,6 +170,8 @@ def _wait_to_retry(self, attempt: int) -> None:
2**attempt, 32
) # Exponential backoff, capped at 32 seconds

backoff_time += random.uniform(0, 1) # Add jitter

time.sleep(backoff_time)

def _get(
Expand Down

0 comments on commit 8db99db

Please sign in to comment.