stop()¶
- Client.stop()¶
Stop the Client.
This method disconnects the client from Telegram and stops the underlying tasks.
- Parameters:
block (
bool, optional) – Blocks the code execution until the client has been stopped. It is useful withblock=Falsein case you want to stop the own client within a handler in order not to cause a deadlock. Defaults to True.clear_handlers (
bool, optional) – Clear the already existing handlers on stop the client. Default to True.
- Returns:
Client– The stopped client itself.- Raises:
ConnectionError – In case you try to stop an already stopped client.
Example
import asyncio from pyrogram import Client async def main(): app = Client("my_account") await app.start() ... # Invoke API methods await app.stop() asyncio.run(main())