Bug 2368594

Summary: python-pytest-twisted fails to build with Python 3.14: RuntimeError: There is no current event loop in thread 'MainThread'.
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-pytest-twistedAssignee: Aurelien Bompard <aurelien>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: aurelien, fti-bugs, ksurma, mhroncok
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2322407, 2339432, 2339435    

Description Karolina Surma 2025-05-26 13:55:48 UTC
python-pytest-twisted fails to build with Python 3.14.0b1.

Creating the ticket for tracking purposes.
twisted doesn't fully work with Python 3.14 yet.
It was reported upstream. Failing twisted tests were skipped for now. But this causes python-pytest-twisted to fail, the fail comes from the codepath that is not prepared for Python 3.14.

======================== 52 passed, 8 skipped in 14.71s ========================
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/_pytest/main.py", line 279, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/_pytest/config/__init__.py", line 1118, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/pluggy/_hooks.py", line 535, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls.copy(), kwargs, False)
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/builddir/build/BUILD/python-pytest-twisted-1.14.3-build/BUILDROOT/usr/lib/python3.14/site-packages/pytest_twisted/__init__.py", line 472, in pytest_configure
INTERNALERROR>     reactor_installers[config.getoption("reactor")]()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/builddir/build/BUILD/python-pytest-twisted-1.14.3-build/BUILDROOT/usr/lib/python3.14/site-packages/pytest_twisted/__init__.py", line 418, in init_asyncio_reactor
INTERNALERROR>     _install_reactor(
INTERNALERROR>     ~~~~~~~~~~~~~~~~^
INTERNALERROR>         reactor_installer=asyncioreactor.install,
INTERNALERROR>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>         reactor_type=asyncioreactor.AsyncioSelectorReactor,
INTERNALERROR>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>     )
INTERNALERROR>     ^
INTERNALERROR>   File "/builddir/build/BUILD/python-pytest-twisted-1.14.3-build/BUILDROOT/usr/lib/python3.14/site-packages/pytest_twisted/__init__.py", line 434, in _install_reactor
INTERNALERROR>     reactor_installer()
INTERNALERROR>     ~~~~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/twisted/internet/asyncioreactor.py", line 304, in install
INTERNALERROR>     reactor = AsyncioSelectorReactor(eventloop)
INTERNALERROR>   File "/usr/lib/python3.14/site-packages/twisted/internet/asyncioreactor.py", line 50, in __init__
INTERNALERROR>     _eventloop: AbstractEventLoop = get_event_loop()
INTERNALERROR>                                     ~~~~~~~~~~~~~~^^
INTERNALERROR>   File "/usr/lib64/python3.14/asyncio/events.py", line 718, in get_event_loop
INTERNALERROR>     raise RuntimeError('There is no current event loop in thread %r.'
INTERNALERROR>                        % threading.current_thread().name)
INTERNALERROR> RuntimeError: There is no current event loop in thread 'MainThread'.


According to https://docs.python.org/dev/whatsnew/3.14.html#id3

Removed implicit creation of event loop by asyncio.get_event_loop(). It now raises a RuntimeError if there is no current event loop. (Contributed by Kumar Aditya in gh-126353.)


https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14-b1/fedora-rawhide-x86_64/09080895-python-pytest-twisted/

For all our attempts to build python-pytest-twisted with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/package/python-pytest-twisted/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14-b1/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Karolina Surma 2025-06-11 16:03:14 UTC
*** Bug 2372082 has been marked as a duplicate of this bug. ***