Skip to content

Commit

Permalink
fix(pingdom.py): enable retry on get checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nefelim4ag committed Oct 21, 2023
1 parent 20fb3da commit 809fac6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/pingdom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
import requests

from tenacity import retry, stop_after_attempt, wait_exponential

class Pingdom:
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token):
Expand Down Expand Up @@ -76,6 +78,10 @@ def __parse_headers(self, headers):
self.req_limit_short = dict(headers).get("req-limit-short")
self.req_limit_long = dict(headers).get("req-limit-long")

@retry(
stop=stop_after_attempt(5), # Maximum number of retries
wait=wait_exponential(multiplier=1, min=1, max=60) # Exponential backoff
)
def checks(self, *args):
response = None
url = self.api_url('checks')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
kubernetes
requests
cachetools
tenacity

0 comments on commit 809fac6

Please sign in to comment.