-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Labels
⚙️ testsaffected functionality: testsaffected functionality: tests🔗 pythonrelated technology: pythonrelated technology: python
Description
Steps to Reproduce
- Run echobot.py on python 3.14
Expected behaviour
It works without any errors
Actual behaviour
The program crashes because there is no event loop.
Operating System
Linux, but this is invariant
Version of Python, python-telegram-bot & dependencies
python-telegram-bot 22.3 (v22.3-0-gc0627124)
Bot API 9.1
Python 3.14.0b4 (main, Jul 8 2025, 21:00:06) [Clang 20.1.4 ]
Relevant log output
/home/harshil/Documents/pyprojects/python-telegram-bot/.venv/lib/python3.14/site-packages/anyio/from_thread.py:119: SyntaxWarning: 'return' in a 'finally' block
return result
Traceback (most recent call last):
File "/home/harshil/Documents/pyprojects/python-telegram-bot/examples/echobot.py", line 71, in <module>
main()
~~~~^^
File "/home/harshil/Documents/pyprojects/python-telegram-bot/examples/echobot.py", line 67, in main
application.run_polling(allowed_updates=Update.ALL_TYPES)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/harshil/Documents/pyprojects/python-telegram-bot/src/telegram/ext/_application.py", line 839, in run_polling
return self.__run(
~~~~~~~~~~^
updater_coroutine=self.updater.start_polling(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<9 lines>...
close_loop=close_loop,
^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/harshil/Documents/pyprojects/python-telegram-bot/src/telegram/ext/_application.py", line 1031, in __run
loop = asyncio.get_event_loop()
File "/home/harshil/.local/share/uv/python/cpython-3.14.0b4-linux-x86_64-gnu/lib/python3.14/asyncio/events.py", line 718, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'MainThread'.
<sys>:0: RuntimeWarning: coroutine 'Updater.start_polling' was never awaited
Additional Context
I don't know how I missed this before, the tests don't catch this probably because pytest-asyncio
creates a new event loop in the background.
Copilot
Metadata
Metadata
Assignees
Labels
⚙️ testsaffected functionality: testsaffected functionality: tests🔗 pythonrelated technology: pythonrelated technology: python