def await_(self, coroutine): """Run given asynchronous coroutine to completion. This prevents a warning from being emitted when it goes out of scope. :param coroutine: A coroutine or a coroutine function """ self.assertIsNotNone( asyncio, msg="Tried to use asyncio on unsupported Python version") loop = asyncio.new_event_loop() if asyncio.iscoroutinefunction(coroutine): coroutine = coroutine(loop) loop.run_until_complete(coroutine) loop.close() return coroutine
def match(self, value): return asyncio and asyncio.iscoroutinefunction(value)