async hydrogram.idle()[source]

Block the main script execution until a signal is received.

This function will run indefinitely in order to block the main script execution and prevent it from exiting while having client(s) that are still running in the background.

It is useful for event-driven application only, that are, applications which react upon incoming Telegram updates through handlers, rather than executing a set of methods sequentially.

Once a signal is received (e.g.: from CTRL+C) the function will terminate and your main script will continue. Don’t forget to call stop() for each running client before the script ends.


import asyncio
from hydrogram import Client, idle

async def main():
    apps = [Client("account1"), Client("account2"), Client("account3")]

    ...  # Set up handlers

    for app in apps:
        await app.start()

    await idle()

    for app in apps:
        await app.stop()