Bug 2165538

Summary: python-more-executors fails to build with Python 3.12: RuntimeError: There is no current event loop in thread 'MainThread'.
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-more-executorsAssignee: Rohan McGovern <rohan>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mhroncok, rohan, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-more-executors-2.11.4-1.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-01 06:03:17 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: 2135404    

Description Tomáš Hrnčiar 2023-01-30 11:59:55 UTC
python-more-executors fails to build with Python 3.12.0a4.

=================================== FAILURES ===================================
___________________________________ test_run ___________________________________

asyncio = <module 'asyncio' from '/usr/lib64/python3.12/asyncio/__init__.py'>

    def test_run(asyncio):
        with AsyncioExecutor(Executors.thread_pool()) as executor:
>           f = executor.submit(sleep_then_return, 0.01, "abc")

tests/test_asyncio.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
more_executors/_impl/asyncio.py:45: in submit
    return self.submit_with_loop(self._loop, *args, **kwargs)
more_executors/_impl/asyncio.py:62: in submit_with_loop
    loop = asyncio.get_event_loop()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

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

    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.12/asyncio/events.py:676: RuntimeError
________________________________ test_with_map _________________________________

asyncio = <module 'asyncio' from '/usr/lib64/python3.12/asyncio/__init__.py'>

    def test_with_map(asyncio):
        with Executors.thread_pool().with_map(lambda x: [x, x]).with_asyncio() as executor:
>           f = executor.submit(sleep_then_return, 0.01, "abc")

tests/test_asyncio.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
more_executors/_impl/asyncio.py:45: in submit
    return self.submit_with_loop(self._loop, *args, **kwargs)
more_executors/_impl/asyncio.py:62: in submit_with_loop
    loop = asyncio.get_event_loop()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

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

    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.12/asyncio/events.py:676: RuntimeError
=============================== warnings summary ===============================
tests/test_poll.py::test_cancel_fn
  /usr/lib/python3.12/site-packages/hamcrest/library/collection/issequence_containinginorder.py:102: DeprecationWarning: deprecated - use contains_exactly(*items)
    warnings.warn("deprecated - use contains_exactly(*items)", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_asyncio.py::test_run - RuntimeError: There is no current ev...
FAILED tests/test_asyncio.py::test_with_map - RuntimeError: There is no curre...
======= 2 failed, 1685 passed, 8 skipped, 1 warning in 115.23s (0:01:55) =======

The get_event_loop() method of the default event loop policy now emits a
DeprecationWarning if there is no current event loop set and it decides to
create one. (Contributed by Serhiy Storchaka and Guido van Rossum in
gh-100160.)

asyncio.get_event_loop() and many other asyncio
functions like ensure_future(), shield() or gather(), and also the
get_event_loop() method of BaseDefaultEventLoopPolicy now raise a RuntimeError
if called when there is no running event loop and the current event loop was
not set. Previously they implicitly created and set a new current event loop.
DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop is set in the policy. (Contributed by Serhiy Storchaka
in gh-93453.)

https://github.com/python/cpython/issues/100160
https://github.com/python/cpython/issues/93453

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

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05251148-python-more-executors/

For all our attempts to build python-more-executors with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-more-executors/

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.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
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 Fedora Update System 2023-02-01 06:01:20 UTC
FEDORA-2023-e53dd292b5 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-e53dd292b5

Comment 2 Fedora Update System 2023-02-01 06:03:17 UTC
FEDORA-2023-e53dd292b5 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.