From 7e2ae22aeec75ce6d4d8606b62809ea189ec76d8 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 14 Nov 2019 12:00:23 +0100 Subject: [PATCH] apply asyncio patch before launching new loop for tests --- notebook/tests/launchnotebook.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/notebook/tests/launchnotebook.py b/notebook/tests/launchnotebook.py index 916d6072d..e84e15642 100644 --- a/notebook/tests/launchnotebook.py +++ b/notebook/tests/launchnotebook.py @@ -140,9 +140,6 @@ class NotebookTestBase(TestCase): started = Event() def start_thread(): - if 'asyncio' in sys.modules: - import asyncio - asyncio.set_event_loop(asyncio.new_event_loop()) app = cls.notebook = NotebookApp( port=cls.port, port_retries=0, @@ -156,6 +153,10 @@ class NotebookTestBase(TestCase): allow_root=True, token=cls.token, ) + if 'asyncio' in sys.modules: + app._init_asyncio_patch() + import asyncio + asyncio.set_event_loop(asyncio.new_event_loop()) # don't register signal handler during tests app.init_signal = lambda : None # clear log handlers and propagate to root for nose to capture it