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

A lot of deprecation warnings in python 3.10 #3033

Closed
vaartis opened this issue May 21, 2021 · 10 comments · Fixed by #3097
Closed

A lot of deprecation warnings in python 3.10 #3033

vaartis opened this issue May 21, 2021 · 10 comments · Fixed by #3097

Comments

@vaartis
Copy link

vaartis commented May 21, 2021

In 3.10, many things that tornado uses were deprecated. This affects things that use tornado, as well as tests that assume there are no deprecation warnings.

Problems I noticed when running tests are:

  • usage of asyncio.get_event_loop, the suggested way is to create a loop manually if needed and otherwise use get_running_loop.
  • usage of ssl.wrap_socket, which is deprecated in favor of using ssl.SSLContext.wrap_socket
  • PROTOCOL_TLS is deprecated, no clear alternative is provided in documentation
  • a lof of ResourceWarning: unclosed <socket.socket fd=543, family=AF_INET, type=SOCK_STREAM, proto=6, laddr=('127.0.0.1', different numbers here)>
@vaartis vaartis changed the title A lof of deprecation warnings in python 3.10 A lot of deprecation warnings in python 3.10 May 21, 2021
@bdarnell
Copy link
Member

usage of asyncio.get_event_loop, the suggested way is to create a loop manually if needed and otherwise use get_running_loop.

Ugh, that one will be painful because it leaks out into application code. I've replied on https://bugs.python.org/issue39529

Will look at the other ones later.

pllim added a commit to astropy/astrowidgets that referenced this issue Oct 22, 2021
@stefanor
Copy link
Contributor

PROTOCOL_TLS is deprecated, no clear alternative is provided in documentation

The options are PROTOCOL_TLS_CLIENT and PROTOCOL_TLS_SERVER, as appropriate.

@GeekDuanLian
Copy link
Contributor

Can use asyncio.get_event_loop_policy().get_event_loop(), which is equivalent to asyncio.get_event_loop(), but does not raise a deprecation warning.

@bdarnell
Copy link
Member

Can use asyncio.get_event_loop_policy().get_event_loop(), which is equivalent to asyncio.get_event_loop(), but does not raise a deprecation warning.

Oh, that would be convenient if that's going to continue to be supported. But my understanding of the changes in https://bugs.python.org/issue39529 is that they intend to get rid of anything that exposes the idea of a "current" event loop except while a loop is running. This would also imply changing the behavior of policy.get_event_loop() even though it doesn't currently have any warnings.

@EwoutH
Copy link

EwoutH commented May 31, 2022

Thanks for fixing this! Any idea when a new release with these changes will be tagged?

@bdarnell
Copy link
Member

I've just released the first beta of Tornado 6.2. Try it out with pip install --pre tornado==6.2.0b1

@bdarnell
Copy link
Member

bdarnell commented Jul 4, 2022

Tornado 6.2 is out today.

@Julienh
Copy link

Julienh commented Jul 14, 2022

Thank you for the update.

I installed Tornado 6.2 today, with Python 3.10.5, I have 2 deprecated warning:

python/envs/3.10.5/lib/python3.10/site-packages/tornado/ioloop.py:265: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()

And

python/envs/3.10.5/lib/python3.10/site-packages/tornado/platform/asyncio.py:299: DeprecationWarning: There is no current event loop
  super().initialize(asyncio.get_event_loop(), **kwargs)

My environment is Debian 10 on WSL.

@bdarnell
Copy link
Member

Yes, you'll need to make changes to your application code to avoid all of the deprecation errors. The changes made in Python 3.10 are unfortunately not something I'm able to completely hide within Tornado. You'll need to change your startup code from something like IOLoop.current().start() to use asyncio.run() instead.

You're not doing anything wrong, by the way. IOLoop.current().start() was the documented and recommended practice until Tornado 6.2. But the asyncio team plans to make extensive changes that will make this mode of operation untenable, so there are a lot of deprecation warnings to force application developers to make the necessary changes.

For now, these are just warnings; nothing will actually break until some (unspecified) future version of python. So you can also just ignore the warnings for a while (and I would be delighted if the asyncio team could be convinced to change their mind about this, because it's a lot of disruption for a benefit that is hard for me to see).

@Julienh
Copy link

Julienh commented Jul 15, 2022

Thank you, I'm using Bottlepy so I think that the problem is coming from this library. I will check.

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.

7 participants
@Julienh @bdarnell @stefanor @GeekDuanLian @vaartis @EwoutH and others