mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-120804: Remove PidfdChildWatcher
, ThreadedChildWatcher
and AbstractChildWatcher
from asyncio APIs (#120893)
This commit is contained in:
parent
b6fa8fe86a
commit
9d2e1ea386
5 changed files with 39 additions and 259 deletions
|
@ -869,31 +869,27 @@ if sys.platform != 'win32':
|
|||
# Unix
|
||||
class SubprocessWatcherMixin(SubprocessMixin):
|
||||
|
||||
Watcher = None
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
policy = asyncio.get_event_loop_policy()
|
||||
self.loop = policy.new_event_loop()
|
||||
self.set_event_loop(self.loop)
|
||||
|
||||
watcher = self._get_watcher()
|
||||
watcher.attach_loop(self.loop)
|
||||
policy._watcher = watcher
|
||||
def test_watcher_implementation(self):
|
||||
loop = self.loop
|
||||
watcher = loop._watcher
|
||||
if unix_events.can_use_pidfd():
|
||||
self.assertIsInstance(watcher, unix_events._PidfdChildWatcher)
|
||||
else:
|
||||
self.assertIsInstance(watcher, unix_events._ThreadedChildWatcher)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
policy = asyncio.get_event_loop_policy()
|
||||
watcher = policy._watcher
|
||||
policy._watcher = None
|
||||
watcher.attach_loop(None)
|
||||
watcher.close()
|
||||
|
||||
class SubprocessThreadedWatcherTests(SubprocessWatcherMixin,
|
||||
test_utils.TestCase):
|
||||
|
||||
def _get_watcher(self):
|
||||
return unix_events.ThreadedChildWatcher()
|
||||
def setUp(self):
|
||||
# Force the use of the threaded child watcher
|
||||
unix_events.can_use_pidfd = mock.Mock(return_value=False)
|
||||
super().setUp()
|
||||
|
||||
@unittest.skipUnless(
|
||||
unix_events.can_use_pidfd(),
|
||||
|
@ -902,9 +898,7 @@ if sys.platform != 'win32':
|
|||
class SubprocessPidfdWatcherTests(SubprocessWatcherMixin,
|
||||
test_utils.TestCase):
|
||||
|
||||
def _get_watcher(self):
|
||||
return unix_events.PidfdChildWatcher()
|
||||
|
||||
pass
|
||||
|
||||
else:
|
||||
# Windows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue