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

Errors caused by asyncio deprecation warning in full test workflow when using python 3.14.0-alpha.1 #3458

Closed
finnagin opened this issue Feb 11, 2025 · 2 comments · Fixed by #3461

Comments

@finnagin
Copy link
Contributor

finnagin commented Feb 11, 2025

I ran into this when test.yml was run for my other pull request, #3457. It looks as though a depreciation warning in asyncio is being raised when running the tests on 3.14. Here is one of the tracebacks:

======================================================================
ERROR: test_write_after_close (tornado.test.websocket_test.WebSocketTest.test_write_after_close)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/tornado/tornado/.tox/py314-full/lib/python3.14/site-packages/tornado/test/websocket_test.py", line 219, in setUp
    super().setUp()
    ~~~~~~~~~~~~~^^
  File "/home/runner/work/tornado/tornado/.tox/py314-full/lib/python3.14/site-packages/tornado/testing.py", line 385, in setUp
    super().setUp()
    ~~~~~~~~~~~~~^^
  File "/home/runner/work/tornado/tornado/.tox/py314-full/lib/python3.14/site-packages/tornado/testing.py", line 162, in setUp
    asyncio.set_event_loop(self.io_loop.asyncio_loop)  # type: ignore[attr-defined]
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.14.0-alpha.4/x64/lib/python3.14/asyncio/events.py", line 843, in set_event_loop
    warnings._deprecated('asyncio.set_event_loop', remove=(3,16))
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.14.0-alpha.4/x64/lib/python3.14/warnings.py", line 668, in _deprecated
    warn(msg, DeprecationWarning, stacklevel=3)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DeprecationWarning: 'asyncio.set_event_loop' is deprecated and slated for removal in Python 3.16

I tried running the tests on different branch without my changes from the PR and it still failed and upon removing the 3.14 tests it succeeded. So, it appears to specifically be an issue with 3.14.

@finnagin
Copy link
Contributor Author

I also found pytest-dev/pytest-asyncio#1025 which appears to be the same issue. According to this comment get_event_loop_policy, set_event_loop_policy, and set_event_loop all trigger the warning.

@bdarnell
Copy link
Member

Yeah, this is the next step in some changes that started in Python 3.10. I think for now we should suppress the deprecation warnings (testing.py:148 is the right place to look for a lot of them). I'm not sure if there's a solution that works in all versions of Python we support (back to 3.9) and isn't deprecated in 3.14. I think we might need asyncio.Runner which was added in 3.11.

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

Successfully merging a pull request may close this issue.

2 participants