Bug 2327989

Summary: python-engineio 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-engineioAssignee: Ben Beasley <code>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 42CC: code, ksurma, manisandro, mhroncok
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-04-13 01:45:11 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:16:43 UTC
python-engineio fails to build with Python 3.14.0a2.

205 tests failed:

_____________________ TornadoTests.test_translate_request ______________________

self = <tests.async.test_tornado.TornadoTests testMethod=test_translate_request>

    def test_translate_request(self):
        mock_handler = mock.MagicMock()
        mock_handler.request.method = 'PUT'
        mock_handler.request.path = '/foo/bar'
        mock_handler.request.query = 'baz=1'
        mock_handler.request.version = '1.1'
        mock_handler.request.headers = {
            'a': 'b',
            'c': 'd',
            'content-type': 'application/json',
            'content-length': 123,
        }
        mock_handler.request.body = b'hello world'
        environ = async_tornado.translate_request(mock_handler)
        expected_environ = {
            'REQUEST_METHOD': 'PUT',
            'PATH_INFO': '/foo/bar',
            'QUERY_STRING': 'baz=1',
            'CONTENT_TYPE': 'application/json',
            'CONTENT_LENGTH': 123,
            'HTTP_A': 'b',
            'HTTP_C': 'd',
            'RAW_URI': '/foo/bar?baz=1',
            'SERVER_PROTOCOL': 'HTTP/1.1',
            # 'wsgi.input': b'hello world',
            'tornado.handler': mock_handler,
        }
        for k, v in expected_environ.items():
            assert v == environ[k]
>       payload = _run(environ['wsgi.input'].read(1))

tests/async/test_tornado.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/async/test_tornado.py:15: in _run
    return asyncio.get_event_loop().run_until_complete(coro)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

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

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


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/08291493-python-engineio/

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

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 Ben Beasley 2024-11-22 19:54:18 UTC
This is not reproducible with Python 3.14.0a1. I will investigate this and/or report it upstream after Python 3.14.0a2 is at least in updates-testing for F41.

Comment 2 Ben Beasley 2024-11-25 13:48:01 UTC
Fixed upstream as of commit a6e5d92ca98b41d2054737c6c49fc0511da0c3c6.

I have a PR to package a post-release snapshot, https://src.fedoraproject.org/rpms/python-engineio/pull-request/11, which should unblock COPR testing with Python 3.14 (successfull build in https://copr.fedorainfracloud.org/coprs/g/python/python3.14/build/8311121/). I’m not planning to merge this PR since it’s possible there won’t be a release before Fedora 43 branching, and I don’t want to ship a snapshot in stable releases if it’s not required.

Comment 3 Aoife Moloney 2025-02-26 13:17:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.

Comment 4 Ben Beasley 2025-04-13 01:45:11 UTC
Fixed in 4.12.0.