pytest-dev/pytest-asyncio

Use of `asyncio.get_event_loop_policy` deprecated in Python 3.14-dev

scop opened this issue · 5 comments

Running 0.25.0 with current Python 3.14-dev yields

DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16

Similarly asyncio.set_event_loop_policy.

Thanks for bringing this to attention!

The asyncio policy deprecation has been coming for quite some time. It's clear that we need to tackle this in pytest-asyncio as well. The preferred way to address the deprecation is to refactor the pytest-asyncio code base accordingly. I'm not sure this is easily possible, though.

Alternatively, we can take a similar approach as for the deprecation of asyncio.get_event_loop. That means refactoring pytest-asyncio to centralize calls to (g|s)et_event_loop_policy into a single function and ignore the warning in that function. That way, the warning doesn't bubble up to user code. We can get away with this for another two Python releases until the warning becomes an error. Hopefully, it doesn't take that long to fully adjust the code base :)

We don't currently test against development versions of Python. Therefore, I don't see the priority of addressing this issue as particularly high.

Adding the ignores to our project to get 3.14 working, the complete list that needs updating is:

  • get_event_loop_policy
  • set_event_loop_policy
  • set_event_loop