Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
[3.11] gh-93453: Only emit deprecation warning in asyncio.get_event_loop when a new event loop is created#99949
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
Merged
ambv merged 6 commits into python:3.11 from serhiy-storchaka:asyncio-get_event_loop2-3.11Dec 6, 2022
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits Select commit Hold shift + click to select a range
28c7d02 gh-93453: Only emit deprecation warning in asyncio.get_event_loop whe…
serhiy-storchaka c6cbcb9 Merge branch '3.11' into asyncio-get_event_loop2-3.11
ambv a7a2804 Restore asyncio._get_event_loop().
serhiy-storchaka 85d3c36 Address review comments.
serhiy-storchaka 8d5072b Merge branch '3.11' into asyncio-get_event_loop2-3.11
serhiy-storchaka 199433c Revert removal of asyncio.events._get_event_loop and _asyncio._get_ev…
ambv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -671,6 +671,21 @@ def get_event_loop(self): | ||
| if (self._local._loop is None and | ||
| not self._local._set_called and | ||
| threading.current_thread() is threading.main_thread()): | ||
| stacklevel = 2 | ||
| try: | ||
| f = sys._getframe(1) | ||
| except AttributeError: | ||
| pass | ||
| else: | ||
| while f: | ||
| module = f.f_globals.get('__name__') | ||
| if not (module == 'asyncio' or module.startswith('asyncio.')): | ||
| break | ||
| f = f.f_back | ||
| stacklevel += 1 | ||
| import warnings | ||
| warnings.warn('There is no current event loop', | ||
| DeprecationWarning, stacklevel=stacklevel) | ||
| self.set_event_loop(self.new_event_loop()) | ||
| if self._local._loop is None: | ||
| @@ -786,12 +801,13 @@ def get_event_loop(): | ||
| def _get_event_loop(stacklevel=3): | ||
ambv marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| # This internal method is going away in Python 3.12, left here only for | ||
| # backwards compatibility with 3.10.0 - 3.10.8 and 3.11.0. | ||
| # Similarly, this method's C equivalent in _asyncio is going away as well. | ||
| # See GH-99949 for more details. | ||
| current_loop = _get_running_loop() | ||
| if current_loop is not None: | ||
| return current_loop | ||
| import warnings | ||
| warnings.warn('There is no current event loop', | ||
| DeprecationWarning, stacklevel=stacklevel) | ||
| return get_event_loop_policy().get_event_loop() | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.