-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Handle deprecations in python 3.10 #3097
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks good to me! @bdarnell Thank you! Looking forward to the release. |
Thorbenl
approved these changes
Jan 3, 2022
Implicit creation of event loops has been deprecated in Python 3.10. Since AnyThreadEventLoopPolicy modifies the rules for implicit loop creation, it is also deprecated.
asyncio.get_event_loop and related methods are deprecated in python 3.10, so deprecate some IOLoop functionality to match. Specifically, make_current, clear_current, and the IOLoop constructor are deprecated in favor of initializing the asyncio event loop and calling IOLoop.current(). (The IOLoop constructor is not deprecated if make_current=False is used. This is useful in test frameworks but is not expected to see general use).
Also avoid deprecated asyncio.get_event_loop in asyncio_test.
The interfaces defined by this class rely on an event loop being "current" even though it is not running; this is incompatible with the future of the asyncio module. It's too big a task to rewrite all the tests right now, so just swallow deprecation warnings for "no current event loop".
Pass a client/server flag to all SSL context creations. This is required to avoid deprecations in Python 3.10. This is a behavior change for client-side connections: certificate verification and hostname checks are now enabled in more situations (previously, the high-level interfaces would generally enforce these requirements but the low-level interfaces like SSLIOStream did not).
bdarnell
force-pushed
the
py310-deprecations
branch
4 times, most recently
from
January 16, 2022 22:06
5130b7d
to
e1a974b
Compare
These tests work in isolation but cause failures in the full suite due to the leftover state of the asyncio event loop. Add cleanup to one test and make another more tolerant of leftover state.
bdarnell
force-pushed
the
py310-deprecations
branch
11 times, most recently
from
January 17, 2022 01:11
eaff438
to
355b9ad
Compare
Now that compatibility between tornado and twisted is based on asyncio, this test isn't very useful any more. It is broken by the deprecations introduced in Python 3.10 and isn't worth reviving.
bdarnell
force-pushed
the
py310-deprecations
branch
4 times, most recently
from
January 17, 2022 03:55
73612fb
to
70908b6
Compare
bdarnell
force-pushed
the
py310-deprecations
branch
from
January 17, 2022 03:58
70908b6
to
1f8aab8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Python 3.10 deprecated a number of things we rely on.
In the future,
asyncio.get_event_loop
will become an alias forget_running_loop
, and anything related to supporting an event loop that is "current" but not running has been deprecated. This is very disruptive for us because that has been the normal mode of operation for tornado during application setup and many testing idioms. For now we need to get the test suite passing, so we catch deprecation warnings in various places and introduce new deprecation warnings to give users better message for things that we'll have to remove.There are no intended changes in behavior except as it relates to deprecation warnings; applications that disable these warnings should be unaffected. In some future version of python, most tornado applications will need to be updated to use newer testing idioms; exactly what that means has not yet been determined.
The
ssl
module has also deprecated some modes of operation with insecure defaults. This PR updates tornado to use the newer modes, which results in a behavior change in some cases. Specifically, client-side usage of SSL will validate server certificates including hostname verification by default in all cases. Previously this was done by higher-level interfaces (like AsyncHTTPClient) but not by the lower-level IOStream or netutil interfaces. Applications that are affected by this should construct assl.SSLContext
object with the appropriate configuration.Fixes #3033