pyrofork/docs/source/faq/code-hangs-when-calling-stop-restart-add-remove-handler.rst
wulan17 261214ec1c
PyroFork: Bring back docs
Signed-off-by: wulan17 <wulan17@nusantararom.org>
2023-08-18 01:42:01 +07:00

12 lines
No EOL
787 B
ReStructuredText

Code hangs when calling 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 Pyrofork deals with handlers would make it hang.
When calling one of the methods above inside an event handler, Pyrofork needs to wait for all running handlers to finish
in order to continue. Since your handler is blocking the execution by waiting for the called method to finish
and since Pyrofork 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.