Skip to content
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

GH-94597: deprecate SafeChildWatcher, FastChildWatcher and MultiLoopChildWatcher child watchers #98089

Merged
merged 4 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
kumaraditya303 authored Oct 8, 2022
commit b6ac303d4e8a2d6cd362f3d35f0968f51a37548d
10 changes: 7 additions & 3 deletions Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import unittest
from unittest import mock
import weakref

import warnings
if sys.platform not in ('win32', 'vxworks'):
import tty

Expand Down Expand Up @@ -2055,7 +2055,9 @@ def test_remove_fds_after_closing(self):
class UnixEventLoopTestsMixin(EventLoopTestsMixin):
def setUp(self):
super().setUp()
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
asyncio.set_child_watcher(watcher)

Expand Down Expand Up @@ -2652,7 +2654,9 @@ def setUp(self):
asyncio.set_event_loop(self.loop)

if sys.platform != 'win32':
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
asyncio.set_child_watcher(watcher)

Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import threading
import unittest
from unittest import mock
import warnings
from test.support import socket_helper
try:
import ssl
Expand Down Expand Up @@ -791,8 +792,9 @@ def test_read_all_from_pipe_reader(self):
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
transport, _ = self.loop.run_until_complete(
self.loop.connect_read_pipe(lambda: protocol, pipe))

watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
try:
asyncio.set_child_watcher(watcher)
Expand Down
21 changes: 16 additions & 5 deletions Lib/test/test_asyncio/test_unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import threading
import unittest
from unittest import mock
import warnings
from test.support import os_helper
from test.support import socket_helper

Expand Down Expand Up @@ -1686,12 +1687,16 @@ def test_close(self, m_waitpid):

class SafeChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
def create_watcher(self):
return asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return asyncio.SafeChildWatcher()


class FastChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
def create_watcher(self):
return asyncio.FastChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return asyncio.FastChildWatcher()


class PolicyTests(unittest.TestCase):
Expand Down Expand Up @@ -1724,7 +1729,9 @@ def test_get_default_child_watcher(self):

def test_get_child_watcher_after_set(self):
policy = self.create_policy()
watcher = asyncio.FastChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
watcher = asyncio.FastChildWatcher()

policy.set_child_watcher(watcher)
self.assertIs(policy._watcher, watcher)
Expand All @@ -1745,7 +1752,9 @@ def f():
policy.get_event_loop().close()

policy = self.create_policy()
policy.set_child_watcher(asyncio.SafeChildWatcher())
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
policy.set_child_watcher(asyncio.SafeChildWatcher())

th = threading.Thread(target=f)
th.start()
Expand All @@ -1757,7 +1766,9 @@ def test_child_watcher_replace_mainloop_existing(self):

# Explicitly setup SafeChildWatcher,
# default ThreadedChildWatcher has no _loop property
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
policy.set_child_watcher(watcher)
watcher.attach_loop(loop)

Expand Down