Bug 2327986

Summary: python-sh 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-shAssignee: Fedora Infrastructure SIG <infra-sig>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: carl, infra-sig, jpena, ksurma, mhroncok, python-packagers-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-sh-2.1.0-2.fc42 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-12-08 21:52:21 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 2024-11-22 10:14:57 UTC
python-sh fails to build with Python 3.14.0a2.

======================================================================
ERROR: test_async_iter_exc (__main__.FunctionalTests.test_async_iter_exc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/python-sh-2.0.6-build/sh-2.0.6/sh_test.py", line 1787, in test_async_iter_exc
    loop = asyncio.get_event_loop()
  File "/usr/lib64/python3.14/asyncio/events.py", line 681, 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'.

---------------------------------------------------------------------
FAILED (errors=4, skipped=1)

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

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

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

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 Carl George 🤠 2024-12-07 08:13:10 UTC
Reported upstream with a corresponding pull request.  I'd like to wait for upstream feedback on the approach I took before including it as a patch in our package.

Comment 2 Carl George 🤠 2024-12-08 21:52:21 UTC
The upstream PR was merged, and I added the fix as a patch to the package.  I forgot to use the bug number in the commit message, but it was built here for Rawhide:

https://bodhi.fedoraproject.org/updates/FEDORA-2024-e9a6904d8f

And I can see it was automatically rebuilt here in the Python 3.14 copr:

https://copr.fedorainfracloud.org/coprs/g/python/python3.14/build/8364185/