repeating food download if error occurred on first try

Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
klux2 2019-10-08 18:38:41 +02:00
parent 29220fa2c5
commit 337d4d15f8

View file

@ -368,7 +368,7 @@ def shutdown(signum, frame):
async def essen_loop() -> None:
global status, essen, ids
global status, essen, ids, var
while True:
now = datetime.datetime.today()
next_day = datetime.datetime(now.year, now.month, now.day) + datetime.timedelta(1, 36000)
@ -378,6 +378,11 @@ async def essen_loop() -> None:
await send_status("Aufwachen um 10 Uhr")
status = "Essen abrufen"
await get_essen(True)
# try again if error
if len(essen) == 0 and var:
await send_status("Fehler, warte 30 Sekunden")
await asyncio.sleep(30)
await get_essen(True)
await send_status("%i Essen gefunden" % len(essen))
status = "Essen senden"
if len(essen) > 0: