Bug 2345521

Summary: pykka 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: pykkaAssignee: Tobi <t-fedora>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ksurma, mhroncok, t-fedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pykka-4.1.2-1.fc43 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-02-16 14:46:41 UTC 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    

Description Karolina Surma 2025-02-13 11:28:48 UTC
pykka fails to build with Python 3.14.05.

_________________ test_future_supports_await_syntax[threading] _________________

future = <pykka.Future>

    def test_future_supports_await_syntax(
        future: Future[int],
    ) -> None:
        async def get_value() -> int:
            return await future
    
        future.set(1)
>       assert run_async(get_value()) == 1

tests/test_future.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_future.py:20: in run_async
    loop = asyncio.get_event_loop()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f6416aaa120>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:719: RuntimeError
______________ test_future_supports_yield_from_syntax[threading] _______________

future = <pykka.Future>

    def test_future_supports_yield_from_syntax(
        future: Future[int],
    ) -> None:
        @types.coroutine
        def get_value() -> Generator[None, None, int]:
            val = yield from future
            return val
    
        future.set(1)
>       assert run_async(get_value()) == 1

tests/test_future.py:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_future.py:20: in run_async
    loop = asyncio.get_event_loop()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f6416aaa120>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:719: RuntimeError
=========================== short test summary info ============================
FAILED tests/test_future.py::test_future_supports_await_syntax[threading] - R...
FAILED tests/test_future.py::test_future_supports_yield_from_syntax[threading]

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/fedora-rawhide-x86_64/08650920-pykka/

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

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/

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 Tobi 2025-02-14 19:14:24 UTC
i've opened a ticket upstream; if i disable the two tests requiring this deprecated feature pykka builds correctly (i haven't had time to test the resulting package).

```
diff --git a/pykka.spec b/pykka.spec
index a78a760..395d657 100644
--- a/pykka.spec
+++ b/pykka.spec
@@ -63,7 +63,7 @@ cp -rp docs/_build/devhelp %{buildroot}%{_datarootdir}/devhelp/%{pypi_name}
 %pyproject_save_files -L pykka
 
 %check
-%pytest tests
+%pytest tests -k 'not test_future_supports_await_syntax and not test_future_supports_yield_from_syntax'
 
 %files -n python3-%{pypi_name} -f %{pyproject_files}
 %license LICENSE
```

there is a newer release available (4.1.1), but that requires pydantic, which isn't built yet for the py314 copr: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-pydantic-core/

Comment 2 Tobi 2025-02-14 19:17:21 UTC
for my own future reference: i ran these tests with `fedpkg mockbuild --root fedora-rawhide-python314` after creating `~/.config/mock/fedora-rawhide-python314.cfg` as per https://copr.fedorainfracloud.org/coprs/g/python/python3.14/.

Comment 3 Fedora Update System 2025-02-16 14:42:33 UTC
FEDORA-2025-39d8cce16c (pykka-4.1.2-1.fc43) has been submitted as an update to Fedora 43.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-39d8cce16c

Comment 4 Fedora Update System 2025-02-16 14:46:41 UTC
FEDORA-2025-39d8cce16c (pykka-4.1.2-1.fc43) has been pushed to the Fedora 43 stable repository.
If problem still persists, please make note of it in this bug report.