8000 deprecate watchers · python/cpython@ba7ddb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba7ddb5

Browse files
deprecate watchers
1 parent 840fd19 commit ba7ddb5

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

Lib/asyncio/unix_events.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,13 @@ class SafeChildWatcher(BaseChildWatcher):
10221022
big number of children (O(n) each time SIGCHLD is raised)
10231023
"""
10241024

1025+
def __init__(self):
1026+
super().__init__()
1027+
warnings._deprecated("SafeChildWatcher",
1028+
"{name!r} is deprecated since Python 3.12 and will be "
1029+
"removed in Python {remove}.",
1030+
remove=(3, 14))
1031+
10251032
def close(self):
10261033
self._callbacks.clear()
10271034
super().close()
@@ -1100,6 +1107,10 @@ def __init__(self):
11001107
self._lock = threading.Lock()
11011108
self._zombies = {}
11021109
self._forks = 0
1110+
warnings._deprecated("FastChildWatcher",
1111+
"{name!r} is deprecated since Python 3.12 and will be "
1112+
"removed in Python {remove}.",
1113+
remove=(3, 14))
11031114

11041115
def close(self):
11051116
self._callbacks.clear()
@@ -1212,6 +1223,10 @@ class MultiLoopChildWatcher(AbstractChildWatcher):
12121223
def __init__(self):
12131224
self._callbacks = {}
12141225
self._saved_sighandler = None
1226+
warnings._deprecated("MultiLoopChildWatcher",
1227+
"{name!r} is deprecated since Python 3.12 and will be "
1228+
"removed in Python {remove}.",
1229+
remove=(3, 14))
12151230

12161231
def is_active(self):
12171232
return self._saved_sighandler is not None

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def setUp(self):
688688
self.loop = policy.new_event_loop()
689689
self.set_event_loop(self.loop)
690690

691-
watcher = self.Watcher()
691+
watcher = self._get_watcher()
692692
watcher.attach_loop(self.loop)
693693
policy.set_child_watcher(watcher)
694694

@@ -703,32 +703,38 @@ def tearDown(self):
703703
class SubprocessThreadedWatcherTests(SubprocessWatcherMixin,
704704
test_utils.TestCase):
705705

706-
Watcher = unix_events.ThreadedChildWatcher
707-
708-
@unittest.skip("bpo-38323: MultiLoopChildWatcher has a race condition \
709-
and these tests can hang the test suite")
710-
class SubprocessMultiLoopWatcherTests(SubprocessWatcherMixin,
711-
test_utils.TestCase):
712-
713-
Watcher = unix_events.MultiLoopChildWatcher
706+
def _get_watcher(self):
707+
return unix_events.ThreadedChildWatcher()
714708

715709
class SubprocessSafeWatcherTests(SubprocessWatcherMixin,
716710
test_utils.TestCase):
717711

718-
Watcher = unix_events.SafeChildWatcher
712+
def _get_watcher(self):
713+
with self.assertWarns(DeprecationWarning):
714+
return unix_events.SafeChildWatcher()
715+
716+
class MultiLoopChildWatcherTests(test_utils.TestCase):
717+
718+
def test_warns(self):
719+
with self.assertWarns(DeprecationWarning):
720+
unix_events.MultiLoopChildWatcher()
719721

720722 class SubprocessFastWatcherTests(SubprocessWatcherMixin,
721723
test_utils.TestCase):
722724

723-
Watcher = unix_events.FastChildWatcher
725+
def _get_watcher(self):
726+
with self.assertWarns(DeprecationWarning):
727+
return unix_events.FastChildWatcher()
724728

725729
@unittest.skipUnless(
726730
_has_pidfd_support(),
727731
"operating system does not support pidfds",
728732
)
729733
class SubprocessPidfdWatcherTests(SubprocessWatcherMixin,
730734
test_utils.TestCase):
731-
Watcher = unix_events.PidfdChildWatcher
735+
736+
def _get_watcher(self):
737+
return unix_events.PidfdChildWatcher()
732738

733739

734740
class GenericWatcherTests(test_utils.TestCase):

0 commit comments

Comments
 (0)
0