diff options
Diffstat (limited to 'Lib/test/test_asyncio/test_windows_events.py')
-rw-r--r-- | Lib/test/test_asyncio/test_windows_events.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py index 13aef7c..1e1c01d 100644 --- a/Lib/test/test_asyncio/test_windows_events.py +++ b/Lib/test/test_asyncio/test_windows_events.py @@ -45,20 +45,21 @@ class ProactorLoopCtrlC(test_utils.TestCase): def test_ctrl_c(self): def SIGINT_after_delay(): - time.sleep(1) + time.sleep(0.1) signal.raise_signal(signal.SIGINT) - asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) - l = asyncio.get_event_loop() + thread = threading.Thread(target=SIGINT_after_delay) + loop = asyncio.get_event_loop() try: - t = threading.Thread(target=SIGINT_after_delay) - t.start() - l.run_forever() + # only start the loop once the event loop is running + loop.call_soon(thread.start) + loop.run_forever() self.fail("should not fall through 'run_forever'") except KeyboardInterrupt: pass finally: - l.close() + self.close_loop(loop) + thread.join() class ProactorTests(test_utils.TestCase): |