def test_ioloop_close_leak(self): orig_count = len(IOLoop._ioloop_for_asyncio) for i in range(10): # Create and close an AsyncIOLoop using Tornado interfaces. loop = AsyncIOLoop() loop.close() new_count = len(IOLoop._ioloop_for_asyncio) - orig_count self.assertEqual(new_count, 0)
def test_ioloop_close_leak(self): orig_count = len(IOLoop._ioloop_for_asyncio) for i in range(10): # Create and close an AsyncIOLoop using Tornado interfaces. with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) loop = AsyncIOLoop() loop.close() new_count = len(IOLoop._ioloop_for_asyncio) - orig_count self.assertEqual(new_count, 0)
def setUp(self): # Trigger a cleanup of the mapping so we start with a clean slate. AsyncIOLoop().close() # If we don't clean up after ourselves other tests may fail on # py34. self.orig_policy = asyncio.get_event_loop_policy() asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
def _launch_client(self, kernel_id): # we have to create the event-loop explicitly here since IOLoop.current() is prohibited outside of the main # thread AsyncIOLoop(make_current=True) # prepare parameters kernel_file = 'kernel-' + kernel_id + '.json' code_to_run = 'from jupyter_singleton.singletonapp import SingletonApp\n' + \ 'SingletonApp.client_started=True' kernel_class = 'jupyter_singleton.singletonipkernel.SingletonIPythonKernel' parameters = { 'connection_file': kernel_file, 'code_to_run': code_to_run, 'quiet': False, 'kernel_class': kernel_class } # start jupyter client self.kernel_app = IPKernelApp(**parameters) self.kernel_app.initialize([]) if hasattr(self.kernel_app.kernel, 'set_displaydatahook'): self.kernel_app.kernel.set_displaydatahook(self.display_data_hook) self.kernel_app.start()
def get_new_ioloop(self): io_loop = AsyncIOLoop() asyncio.set_event_loop(io_loop.asyncio_loop) demonstration.from_thread = partial( io_loop.asyncio_loop.run_in_executor, None) return io_loop
def get_new_ioloop(self): io_loop = AsyncIOLoop() return io_loop
def get_new_ioloop(self): io_loop = AsyncIOLoop() asyncio.set_event_loop(io_loop.asyncio_loop) return io_loop
def get_new_ioloop(self): io_loop = AsyncIOLoop(make_current=False) return io_loop