def get_new_ioloop(self): """Returns the `.IOLoop` to use for this test. By default, a new `.IOLoop` is created for each test. Subclasses may override this method to return `.IOLoop.current()` if it is not appropriate to use a new `.IOLoop` in each tests (for example, if there are global singletons using the default `.IOLoop`) or if a per-test event loop is being provided by another system (such as ``pytest-asyncio``). """ return IOLoop()
def __init__(self, async_client_class=None, **kwargs): # Initialize self._closed at the beginning of the constructor # so that an exception raised here doesn't lead to confusing # failures in __del__. self._closed = True self._io_loop = IOLoop(make_current=False) if async_client_class is None: async_client_class = AsyncHTTPClient # Create the client while our IOLoop is "current", without # clobbering the thread's real current IOLoop (if any). self._async_client = self._io_loop.run_sync( gen.coroutine(lambda: async_client_class(**kwargs))) self._closed = False
def __init__(self): # always use a new ioloop IOLoop.clear_current() IOLoop(make_current=True) super(_TestReactor, self).__init__() IOLoop.clear_current()