From 0aae0563d58fce441057e000a3a131a0f039faf5 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Mon, 3 Jun 2019 00:16:30 +0300 Subject: [PATCH 1/3] Fix tests when SafeChildWatcher is expected instead of ThreadedChildWatcher --- Lib/test/test_asyncio/test_unix_events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index f7f992fcea49f9..7fd1eecf041ee9 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -1824,8 +1824,6 @@ def test_get_child_watcher_after_set(self): def test_get_child_watcher_thread(self): def f(): - policy.set_event_loop(policy.new_event_loop()) - self.assertIsInstance(policy.get_event_loop(), asyncio.AbstractEventLoop) watcher = policy.get_child_watcher() @@ -1836,6 +1834,8 @@ def f(): policy.get_event_loop().close() policy = self.create_policy() + policy.set_child_watcher(asyncio.SafeChildWatcher()) + policy.set_event_loop(policy.new_event_loop()) th = threading.Thread(target=f) th.start() From 7216c6fe7d67d75eb4017377f4373aec5ea67476 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Mon, 3 Jun 2019 00:48:52 +0300 Subject: [PATCH 2/3] Set policy in the right place --- Lib/test/test_asyncio/test_unix_events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 7fd1eecf041ee9..51355ae1ebed80 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -1824,6 +1824,7 @@ def test_get_child_watcher_after_set(self): def test_get_child_watcher_thread(self): def f(): + policy.set_event_loop(policy.new_event_loop()) self.assertIsInstance(policy.get_event_loop(), asyncio.AbstractEventLoop) watcher = policy.get_child_watcher() @@ -1835,7 +1836,6 @@ def f(): policy = self.create_policy() policy.set_child_watcher(asyncio.SafeChildWatcher()) - policy.set_event_loop(policy.new_event_loop()) th = threading.Thread(target=f) th.start() From e930712882e44aecadc67d2e707643eacc5ecb4e Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Mon, 3 Jun 2019 00:49:34 +0300 Subject: [PATCH 3/3] Fix spaces --- Lib/test/test_asyncio/test_unix_events.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 51355ae1ebed80..462a8b3c785917 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -1825,6 +1825,7 @@ def test_get_child_watcher_thread(self): def f(): policy.set_event_loop(policy.new_event_loop()) + self.assertIsInstance(policy.get_event_loop(), asyncio.AbstractEventLoop) watcher = policy.get_child_watcher()