mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Add FAQ about why stop, restart, add/remove_handler could make the code hang
This commit is contained in:
parent
012369005e
commit
227a5aaf90
@ -253,6 +253,19 @@ contact people using official apps. The answer is the same for Pyrogram too and
|
|||||||
for usernames, meeting them in a common group, have their phone contacts saved or getting a message mentioning them,
|
for usernames, meeting them in a common group, have their phone contacts saved or getting a message mentioning them,
|
||||||
either a forward or a mention in the message text.
|
either a forward or a mention in the message text.
|
||||||
|
|
||||||
|
Code hangs when I stop, restart, add/remove_handler
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
You tried to ``.stop()``, ``.restart()``, ``.add_handler()`` or ``.remove_handler()`` *inside* a running handler, but
|
||||||
|
that can't be done because the way Pyrogram deals with handlers would make it hang.
|
||||||
|
|
||||||
|
When calling one of the methods above inside an event handler, Pyrogram needs to wait for all running handlers to finish
|
||||||
|
in order to safely continue. In other words, since your handler is blocking the execution by waiting for the called
|
||||||
|
method to finish and since Pyrogram needs to wait for your handler to finish, you are left with a deadlock.
|
||||||
|
|
||||||
|
The solution to this problem is to pass ``block=False`` to such methods so that they return immediately and the actual
|
||||||
|
code called asynchronously.
|
||||||
|
|
||||||
UnicodeEncodeError: '<encoding>' codec can't encode …
|
UnicodeEncodeError: '<encoding>' codec can't encode …
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user