Start the client, idle the main script and finally stop the client.

When calling this method without any argument it acts as a convenience method that calls start(), idle() and stop() in sequence. It makes running a single client less verbose.

In case a coroutine is passed as argument, runs the coroutine until it’s completed and doesn’t do any client operation. This is almost the same as except for the fact that Hydrogram’s run uses the current event loop instead of a new one.

If you want to run multiple clients at once, see hydrogram.compose().


coroutine (Coroutine, optional) – Pass a coroutine to run it until it completes.


ConnectionError – In case you try to run an already started client.


from hydrogram import Client

app = Client("my_account")
...  # Set handlers up
from hydrogram import Client

app = Client("my_account")

async def main():
    async with app:
        print(await app.get_me())