Skip to content

No current event loop on Python 3.14 #4874

@harshil21

Description

@harshil21

Steps to Reproduce

  1. 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.

Metadata

Metadata

Assignees

Labels

⚙️ testsaffected functionality: tests🔗 pythonrelated technology: python

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy