Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2dc5d6196a464d9020f369deba5dacc1378be66c37d15f5a59929eecFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -195,30 +195,32 @@ 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) | ||
Contributor 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 | ||
| @@ -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 | ||
| 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. |
Uh oh!
There was an error while loading. Please reload this page.