diff --git a/docs/source/inclusions/application_run_tip.rst b/docs/source/inclusions/application_run_tip.rst new file mode 100644 index 00000000000..f6b1261b26d --- /dev/null +++ b/docs/source/inclusions/application_run_tip.rst @@ -0,0 +1,7 @@ +.. tip:: + When combining ``python-telegram-bot`` with other :mod:`asyncio` based frameworks, using this + method is likely not the best choice, as it blocks the event loop until it receives a stop + signal as described above. + Instead, you can manually call the methods listed below to start and shut down the application + and the :attr:`~telegram.ext.Application.updater`. + Keeping the event loop running and listening for a stop signal is then up to you. \ No newline at end of file diff --git a/telegram/ext/_application.py b/telegram/ext/_application.py index 233d78fe23c..eab0bc90212 100644 --- a/telegram/ext/_application.py +++ b/telegram/ext/_application.py @@ -592,9 +592,12 @@ def run_polling( If :attr:`post_shutdown` is set, it will be called after both :meth:`shutdown` and :meth:`telegram.ext.Updater.shutdown`. + .. include:: inclusions/application_run_tip.rst + .. seealso:: :meth:`initialize`, :meth:`start`, :meth:`stop`, :meth:`shutdown` - :meth:`telegram.ext.Updater.start_polling`, :meth:`run_webhook` + :meth:`telegram.ext.Updater.start_polling`, :meth:`telegram.ext.Updater.stop`, + :meth:`run_webhook` Args: poll_interval (:obj:`float`, optional): Time to wait between polling updates from @@ -705,9 +708,12 @@ def run_webhook( If :attr:`post_shutdown` is set, it will be called after both :meth:`shutdown` and :meth:`telegram.ext.Updater.shutdown`. + .. include:: inclusions/application_run_tip.rst + .. seealso:: :meth:`initialize`, :meth:`start`, :meth:`stop`, :meth:`shutdown` - :meth:`telegram.ext.Updater.start_webhook`, :meth:`run_polling` + :meth:`telegram.ext.Updater.start_webhook`, :meth:`telegram.ext.Updater.stop`, + :meth:`run_polling` Args: listen (:obj:`str`, optional): IP-Address to listen on. Defaults to