mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-22 05:24:54 +01:00
usage of retry-after header information in bf api call
This commit is contained in:
parent
c26891180d
commit
591f933db0
2 changed files with 13 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.4.2"
|
__version__ = "4.4.3.a1"
|
||||||
__codename__ = "Yeast Starter"
|
__codename__ = "Yeast Starter"
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,19 @@ class UploadController:
|
||||||
async with aiohttp.ClientSession(headers=headers) as bf_session:
|
async with aiohttp.ClientSession(headers=headers) as bf_session:
|
||||||
async with bf_session.get(self.url, params=parameters) as r:
|
async with bf_session.get(self.url, params=parameters) as r:
|
||||||
if r.status == 429:
|
if r.status == 429:
|
||||||
logging.error("Too many requests to BF api. Try again later")
|
try:
|
||||||
self.cbpi.notify("Error", "Too many requests to BF api. Try again later", NotificationType.ERROR)
|
seconds=int(r.headers['Retry-After'])
|
||||||
|
minutes=round(seconds/60)
|
||||||
|
except:
|
||||||
|
seconds=None
|
||||||
|
if not seconds:
|
||||||
|
logging.error("Too many requests to BF api. Try again later")
|
||||||
|
self.cbpi.notify("Error", "Too many requests to BF api. Try again later", NotificationType.ERROR)
|
||||||
|
else:
|
||||||
|
logging.error(f"Too many requests to BF api. Try in {minutes} minutes again.")
|
||||||
|
self.cbpi.notify("Error", f"Too many requests to BF api. Try in {minutes} minutes again.", NotificationType.ERROR)
|
||||||
repeat = False
|
repeat = False
|
||||||
|
logging.error(r.headers['Retry-After'])
|
||||||
else:
|
else:
|
||||||
bf_recipe_list = await r.json()
|
bf_recipe_list = await r.json()
|
||||||
await bf_session.close()
|
await bf_session.close()
|
||||||
|
|
Loading…
Reference in a new issue