summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/asyncio-policy.rst3
-rw-r--r--Doc/whatsnew/3.12.rst4
-rw-r--r--Lib/asyncio/unix_events.py7
-rw-r--r--Lib/test/test_asyncio/test_unix_events.py9
-rw-r--r--Misc/NEWS.d/next/Library/2022-11-11-18-23-41.gh-issue-94597.m6vMDK.rst1
5 files changed, 21 insertions, 3 deletions
diff --git a/Doc/library/asyncio-policy.rst b/Doc/library/asyncio-policy.rst
index 052378e..98c8501 100644
--- a/Doc/library/asyncio-policy.rst
+++ b/Doc/library/asyncio-policy.rst
@@ -222,6 +222,9 @@ implementation used by the asyncio event loop:
This method has to be called to ensure that underlying
resources are cleaned-up.
+ .. deprecated:: 3.12
+
+
.. class:: ThreadedChildWatcher
This implementation starts a new waiting thread for every subprocess spawn.
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index 37b9fb1..ead2a9e 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -203,8 +203,8 @@ asyncio
(Contributed by Kumar Aditya in :gh:`98024`.)
* The child watcher classes :class:`~asyncio.MultiLoopChildWatcher`,
- :class:`~asyncio.FastChildWatcher` and
- :class:`~asyncio.SafeChildWatcher` are deprecated and
+ :class:`~asyncio.FastChildWatcher`, :class:`~asyncio.AbstractChildWatcher`
+ and :class:`~asyncio.SafeChildWatcher` are deprecated and
will be removed in Python 3.14. It is recommended to not manually
configure a child watcher as the event loop now uses the best available
child watcher for each platform (:class:`~asyncio.PidfdChildWatcher`
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 2de7a1b..b21e039 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -846,6 +846,13 @@ class AbstractChildWatcher:
waitpid(-1), there should be only one active object per process.
"""
+ def __init_subclass__(cls) -> None:
+ if cls.__module__ != __name__:
+ warnings._deprecated("AbstractChildWatcher",
+ "{name!r} is deprecated as of Python 3.12 and will be "
+ "removed in Python {remove}.",
+ remove=(3, 14))
+
def add_child_handler(self, pid, callback, *args):
"""Register a new child handler.
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
index d806ed4..93e8611 100644
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -1108,6 +1108,11 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
class AbstractChildWatcherTests(unittest.TestCase):
+ def test_warns_on_subclassing(self):
+ with self.assertWarns(DeprecationWarning):
+ class MyWatcher(asyncio.AbstractChildWatcher):
+ pass
+
def test_not_implemented(self):
f = mock.Mock()
watcher = asyncio.AbstractChildWatcher()
@@ -1747,7 +1752,9 @@ class PolicyTests(unittest.TestCase):
self.assertIsInstance(policy.get_event_loop(),
asyncio.AbstractEventLoop)
- watcher = policy.get_child_watcher()
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ watcher = policy.get_child_watcher()
self.assertIsInstance(watcher, asyncio.SafeChildWatcher)
self.assertIsNone(watcher._loop)
diff --git a/Misc/NEWS.d/next/Library/2022-11-11-18-23-41.gh-issue-94597.m6vMDK.rst b/Misc/NEWS.d/next/Library/2022-11-11-18-23-41.gh-issue-94597.m6vMDK.rst
new file mode 100644
index 0000000..5e649a8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-11-11-18-23-41.gh-issue-94597.m6vMDK.rst
@@ -0,0 +1 @@
+Deprecate :class:`asyncio.AbstractChildWatcher` to be removed in Python 3.14. Patch by Kumar Aditya.