def get_new_ioloop(self) -> IOLoop: """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: "Optional[Type[AsyncHTTPClient]]" = None, **kwargs: Any ) -> None: # 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). async def make_client() -> "AsyncHTTPClient": await gen.sleep(0) assert async_client_class is not None return async_client_class(**kwargs) self._async_client = self._io_loop.run_sync(make_client) self._closed = False