fix: asyncio Fallback-Loop fuer daily_forecast (kein JobQueue)
This commit is contained in:
parent
c4553b46d7
commit
4202926830
2 changed files with 17 additions and 0 deletions
Binary file not shown.
|
|
@ -973,12 +973,29 @@ def main():
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("Fehler im Filmtipp-Loop")
|
log.exception("Fehler im Filmtipp-Loop")
|
||||||
|
|
||||||
|
async def _forecast_loop(application):
|
||||||
|
"""Fallback: asyncio-basierter täglicher Forecast (08:00 Uhr)."""
|
||||||
|
while True:
|
||||||
|
now = datetime.now()
|
||||||
|
target = now.replace(hour=8, minute=0, second=0, microsecond=0)
|
||||||
|
if now >= target:
|
||||||
|
from datetime import timedelta
|
||||||
|
target += timedelta(days=1)
|
||||||
|
wait_secs = (target - now).total_seconds()
|
||||||
|
log.info("Forecast-Loop: nächster Run in %.0f Sek (%s)", wait_secs, target)
|
||||||
|
await asyncio.sleep(wait_secs)
|
||||||
|
try:
|
||||||
|
await _send_daily_forecast(application)
|
||||||
|
except Exception:
|
||||||
|
log.exception("Fehler im Forecast-Loop")
|
||||||
|
|
||||||
async def post_init(application):
|
async def post_init(application):
|
||||||
await application.bot.set_my_commands(BOT_COMMANDS)
|
await application.bot.set_my_commands(BOT_COMMANDS)
|
||||||
log.info("Kommandomenü registriert")
|
log.info("Kommandomenü registriert")
|
||||||
asyncio.create_task(_watchdog_loop())
|
asyncio.create_task(_watchdog_loop())
|
||||||
if application.job_queue is None:
|
if application.job_queue is None:
|
||||||
asyncio.create_task(_filmtipp_loop(application))
|
asyncio.create_task(_filmtipp_loop(application))
|
||||||
|
asyncio.create_task(_forecast_loop(application))
|
||||||
_sd_notify("READY=1")
|
_sd_notify("READY=1")
|
||||||
log.info("Systemd Watchdog aktiv (50s Intervall)")
|
log.info("Systemd Watchdog aktiv (50s Intervall)")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue