Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-100160: Restore and deprecate implicit creation of an event loop#100410
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
serhiy-storchaka merged 7 commits into python:main from serhiy-storchaka:asyncio-get_event_loop3-3.12Jan 13, 2023
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
7 commits Select commit Hold shift + click to select a range
8800552 gh-100160: Deprecate implicit creation of an event loop
serhiy-storchaka 711efbf Apply suggestions from code review
serhiy-storchaka 0feec4c Apply suggestions from the code review.
serhiy-storchaka 0976177 Merge branch 'asyncio-get_event_loop3-3.12' of github.com:serhiy-stor…
serhiy-storchaka ee1242d Merge branch 'main' into asyncio-get_event_loop3-3.12
serhiy-storchaka 1e22c6f Tweak the documentation.
serhiy-storchaka cc34df5 Merge branch 'main' into asyncio-get_event_loop3-3.12
serhiy-storchaka 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
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 |
|---|---|---|
| @@ -619,7 +619,7 @@ def get_event_loop(self): | ||
| Returns an event loop object implementing the BaseEventLoop interface, | ||
| or raises an exception in case no event loop has been set for the | ||
| current context. | ||
| current context and the current policy does not specify to create one. | ||
| It should never return None.""" | ||
| raise NotImplementedError | ||
| @@ -672,6 +672,28 @@ def get_event_loop(self): | ||
| Returns an instance of EventLoop or raises an exception. | ||
| """ | ||
| 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: | ||
| # Move up the call stack so that the warning is attached | ||
| # to the line outside asyncio itself. | ||
| 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 | ||
serhiy-storchaka marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| 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: | ||
| raise RuntimeError('There is no current event loop in thread %r.' | ||
| % threading.current_thread().name) | ||
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
3 changes: 3 additions & 0 deletions 3 Misc/NEWS.d/next/Library/2022-12-21-17-49-50.gh-issue-100160.N0NHRj.rst
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Emit a deprecation warning in | ||
| :meth:`asyncio.DefaultEventLoopPolicy.get_event_loop` if there is no current | ||
| event loop set and it decides to create one. |
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.