Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python 3.12] py35_asyncio_async_def raises RuntimeError: There is no current event loop in thread 'MainThread'. #5183

Closed
hroncok opened this issue Dec 21, 2022 · 1 comment
Labels
Milestone

Comments

@hroncok
Copy link
Contributor

hroncok commented Dec 21, 2022

Describe the bug

We have this test failure in Fedora with Python 3.12.0a3:

Traceback (most recent call last):
  File "/builddir/build/BUILD/cython-0.29.32/TEST_TMP/0/run/py35_asyncio_async_def/main.py", line 9, in <module>
    with closing(asyncio.get_event_loop()) as loop:
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/events.py", line 676, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'.

This is from 0.29.32 but I see the same code in the master branch:

with closing(asyncio.get_event_loop()) as loop:

Code to reproduce the behaviour:

Run tests with Python 3.12.0a3.

Expected behaviour

Tests pass.

Environment

OS: Fedora Linux
Python version: 3.12.0a3
Cython version: 0.29.32 or master branch

Additional context

https://docs.python.org/3.12/whatsnew/3.12.html#changes-in-the-python-api

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

da-woods added a commit to da-woods/cython that referenced this issue Dec 31, 2022
The behaviour of creating a new event loop if one doesn't
already exist was removed in Python 3.12 alpha and was allegedly
deprecated before then.

Fixes cython#5183
@scoder scoder added this to the 0.29.33 milestone Jan 4, 2023
scoder pushed a commit that referenced this issue Jan 4, 2023
The behaviour of creating a new event loop if one doesn't
already exist was removed in Python 3.12 alpha and was allegedly
deprecated before then.

Fixes #5183
@scoder
Copy link
Contributor

scoder commented Jan 4, 2023

Closed in #5188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants