Compatibility with Python 3.12 - RuntimeError: There is no current event loop in thread 'MainThread'.
hrnciar opened this issue · 0 comments
hrnciar commented
Hello,
in Fedora, we are rebuilding all Python packages with the upcoming Python 3.12 (currently 5th alpha). I am getting this error:
RuntimeError: There is no current event loop in thread 'MainThread'.
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 python/cpython#100160.)
======================================================================
ERROR: test_before_after (tests.test.CoroutineTestCase.test_before_after)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/decorator-5.1.1/src/tests/test.py", line 42, in test_before_after
out = get_event_loop().run_until_complete(coro('x'))
^^^^^^^^^^^^^^^^
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'.
======================================================================
ERROR: test_coro_to_func (tests.test.CoroutineTestCase.test_coro_to_func)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/decorator-5.1.1/src/tests/test.py", line 50, in test_coro_to_func
self.assertEqual(coro('x'), 'x')
^^^^^^^^^
File "/builddir/build/BUILD/decorator-5.1.1/src/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/decorator-5.1.1/src/tests/test.py", line 33, in coro_to_func
return get_event_loop().run_until_complete(coro(*args, **kw))
^^^^^^^^^^^^^^^^
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'.
----------------------------------------------------------------------
Ran 24 tests in 5.829s
FAILED (errors=2)