-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-94597: Deprecate child watcher getters and setters #98215
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
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2dc5d61
deprecate config methods
kumaraditya303 96a464d
whitespace
kumaraditya303 9020f36
📜🤖 Added by blurb_it.
blurb-it[bot] 9deba5d
Merge branch 'main' into watcher
kumaraditya303 acc1378
fix return indent
kumaraditya303 be66c37
add whatsnew
kumaraditya303 d15f5a5
nl
kumaraditya303 9929eec
Merge branch 'main' into watcher
kumaraditya303 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,32 +195,34 @@ def _make_write_pipe_transport(self, pipe, protocol, waiter=None, | |
async def _make_subprocess_transport(self, protocol, args, shell, | ||
stdin, stdout, stderr, bufsize, | ||
extra=None, **kwargs): | ||
with events.get_child_watcher() as watcher: | ||
if not watcher.is_active(): | ||
# Check early. | ||
# Raising exception before process creation | ||
# prevents subprocess execution if the watcher | ||
# is not ready to handle it. | ||
raise RuntimeError("asyncio.get_child_watcher() is not activated, " | ||
"subprocess support is not installed.") | ||
waiter = self.create_future() | ||
transp = _UnixSubprocessTransport(self, protocol, args, shell, | ||
stdin, stdout, stderr, bufsize, | ||
waiter=waiter, extra=extra, | ||
**kwargs) | ||
|
||
watcher.add_child_handler(transp.get_pid(), | ||
self._child_watcher_callback, transp) | ||
try: | ||
await waiter | ||
except (SystemExit, KeyboardInterrupt): | ||
raise | ||
except BaseException: | ||
transp.close() | ||
await transp._wait() | ||
raise | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter('ignore', DeprecationWarning) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't safe to disable warnings here, this is a process global and you're disabiling it for the whole wait |
||
with events.get_child_watcher() as watcher: | ||
if not watcher.is_active(): | ||
# Check early. | ||
# Raising exception before process creation | ||
# prevents subprocess execution if the watcher | ||
# is not ready to handle it. | ||
raise RuntimeError("asyncio.get_child_watcher() is not activated, " | ||
"subprocess support is not installed.") | ||
waiter = self.create_future() | ||
transp = _UnixSubprocessTransport(self, protocol, args, shell, | ||
stdin, stdout, stderr, bufsize, | ||
waiter=waiter, extra=extra, | ||
**kwargs) | ||
|
||
watcher.add_child_handler(transp.get_pid(), | ||
self._child_watcher_callback, transp) | ||
try: | ||
await waiter | ||
except (SystemExit, KeyboardInterrupt): | ||
raise | ||
except BaseException: | ||
transp.close() | ||
await transp._wait() | ||
raise | ||
|
||
return transp | ||
return transp | ||
kumaraditya303 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def _child_watcher_callback(self, pid, returncode, transp): | ||
# Skip one iteration for callbacks to be executed | ||
|
@@ -1469,6 +1471,9 @@ def get_child_watcher(self): | |
if self._watcher is None: | ||
self._init_watcher() | ||
|
||
warnings._deprecated("get_child_watcher", | ||
"{name!r} is deprecated as of Python 3.12 and will be " | ||
"removed in Python {remove}.", remove=(3, 14)) | ||
return self._watcher | ||
|
||
def set_child_watcher(self, watcher): | ||
|
@@ -1480,6 +1485,9 @@ def set_child_watcher(self, watcher): | |
self._watcher.close() | ||
|
||
self._watcher = watcher | ||
warnings._deprecated("set_child_watcher", | ||
"{name!r} is deprecated as of Python 3.12 and will be " | ||
"removed in Python {remove}.", remove=(3, 14)) | ||
|
||
|
||
SelectorEventLoop = _UnixSelectorEventLoop | ||
|
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
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2022-10-12-11-20-54.gh-issue-94597.GYJZlb.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 @@ | ||
Deprecated :meth:`asyncio.AbstractEventLoopPolicy.get_child_watcher` and :meth:`asyncio.AbstractEventLoopPolicy.set_child_watcher` methods to be removed in Python 3.14. Patch by Kumar Aditya. |
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.