INNER CODE UNIT · Python
restart_loop
thevickypedia/Jarvis · jarvis/api/background_task/bot.py:46
async def restart_loop(after: int) -> None:
"""Restart telegram polling.
Args:
after: Delay in seconds.
See Also:
- Stops telegram polling immediately.
- Sleeps for the mentioned delay.
- Sets the restart_loop flag to true.
"""
# Stop polling immediately in the main loop
telegram_beat.poll_for_messages = False
# Sleep for the # of seconds after which the loop should be restarted
await asyncio.sleep(after)
# Set restart loop to True, which will re-trigger init with 3s trials
telegram_beat.restart_loop = True