From ccadabca4a6a6e6ba2da12d88b51573da855fac7 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:56:07 +0200 Subject: [PATCH] Update documentation --- docs/source/index.rst | 4 ++-- docs/source/topics/speedups.rst | 25 ++++++++++++++++++++++++- docs/source/topics/synchronous.rst | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 885f79dd..d4699d54 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -141,9 +141,9 @@ Meta topics/create-filters topics/more-on-updates topics/client-settings - topics/synchronous - topics/text-formatting topics/speedups + topics/text-formatting + topics/synchronous topics/smart-plugins topics/storage-engines topics/serializing diff --git a/docs/source/topics/speedups.rst b/docs/source/topics/speedups.rst index 6340e1ad..821b26f4 100644 --- a/docs/source/topics/speedups.rst +++ b/docs/source/topics/speedups.rst @@ -45,21 +45,44 @@ Installation Usage ^^^^^ -Call ``uvloop.install()`` before calling ``asyncio.run()`` or ``app.run()`` +Call ``uvloop.install()`` before calling ``asyncio.run()`` or ``app.run()``. .. code-block:: python import asyncio import uvloop + from pyrogram import Client + + async def main(): app = Client("my_account") async with app: print(await app.get_me()) + uvloop.install() asyncio.run(main()) +The ``uvloop.install()`` call also needs to be placed before creating a Client instance. + +.. code-block:: python + + import uvloop + from pyrogram import Client + + uvloop.install() + + app = Client("my_account") + + + @app.on_message() + async def hello(client, message): + print(await client.get_me()) + + + app.run() + .. _TgCrypto: https://github.com/pyrogram/tgcrypto .. _uvloop: https://github.com/MagicStack/uvloop diff --git a/docs/source/topics/synchronous.rst b/docs/source/topics/synchronous.rst index e082f18c..a6e12383 100644 --- a/docs/source/topics/synchronous.rst +++ b/docs/source/topics/synchronous.rst @@ -71,3 +71,18 @@ possible. @app.on_edited_message() def handler2(client, message): message.forward("me") + +uvloop usage +------------ + +When using Pyrogram in its synchronous mode combined with uvloop, you need to call ``uvloop.install()`` before importing +Pyrogram. + +.. code-block:: python + + import uvloop + uvloop.install() + + from pyrogram import Client + + ... \ No newline at end of file