litl / backoff

Python library providing function decorators for configurable backoff and retry
MIT License
2.61k stars 148 forks source link

How do I use this? #180

Open wprojects opened 2 years ago

wprojects commented 2 years ago

I have an api I'm trying to hit with the code below. How do I implement this code I have into backoff? I don't see any example and I'm confused on how to apply this to my code

daily = "min_time=-1%20day&bucket=day" weekly = "min_time=-1%20week&bucket=week" monthly = "min_time=-4%20week&bucket=week" headers = {'User-Agent': 'a1projects/1.0'} url = "https://api.helium.io/v1/hotspots/" + address +"/rewards/sum?"+daily response = r.get(url, headers=headers)#.json() if str(response) == "<Response [200]>": time.sleep(.6) response = response.json() data = response['data'][0] daily_rewards = data['total'] daily_rewards = f"{daily_rewards:.2f}"