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

Python 3.10: tests fail due to DeprecationWarning: There is no current event loop #1443

Closed
mgorny opened this issue May 18, 2021 · 2 comments
Labels
Milestone

Comments

@mgorny
Copy link
Contributor

mgorny commented May 18, 2021

The test suite is failing against Python 3.10.0b1 due to a lot of DeprecationWarnings, e.g.:

==================================================================== FAILURES ====================================================================
________________________________________________________________ test_basic_async ________________________________________________________________
tests/test_async.py:29: in test_basic_async
    rv = run(func())
tests/test_async.py:17: in run
    loop = asyncio.get_event_loop()
E   DeprecationWarning: There is no current event loop
______________________________________________________________ test_await_on_calls _______________________________________________________________
tests/test_async.py:45: in test_await_on_calls
    rv = run(func())
tests/test_async.py:17: in run
    loop = asyncio.get_event_loop()
E   DeprecationWarning: There is no current event loop
_______________________________________________________ test_await_on_calls_normal_render ________________________________________________________
tests/test_async.py:58: in test_await_on_calls_normal_render
    rv = t.render(async_func=async_func, normal_func=normal_func)
.tox/py310/lib/python3.10/site-packages/jinja2/environment.py:1281: in render
    loop = asyncio.get_event_loop()
E   DeprecationWarning: There is no current event loop
[...]

To reproduce:

tox -e py310

Environment:

  • Python version: 3.10.0b1
  • Jinja version: ab78403
@davidism
Copy link
Member

Using asyncio.run() should fix this, and will be possible when we drop Python 3.6 support in December. I guess if we want to avoid the warning before then we can replace get_event_loop with

if sys.version_info < (3, 7):
    loop = asyncio.get_event_loop()
    loop.run_until_complete(...)
else:
    asyncio.run(...)

@davidism davidism mentioned this issue May 18, 2021
6 tasks
@davidism davidism added this to the 3.0.1 milestone May 18, 2021
@davidism davidism added the async label May 18, 2021
@mgorny
Copy link
Contributor Author

mgorny commented May 18, 2021

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants