async def update_lifetime(loop: asyncio.BaseEventLoop, ev: asyncio.Event, lifetime: int): i = 0 while not ev.is_set(): logger.info("update lifetime:%d %d", i, lifetime + 20) # xxx: +20? await asyncio.wait([loop.run_in_executor(None, _do), asyncio.sleep(1)]) i += 1
async def update_lifetime( loop: asyncio.BaseEventLoop, ev: asyncio.Event, lifetime: int ): i = 0 while not ev.is_set(): logger.info("update lifetime:%d %d", i, lifetime + 20) # xxx: +20? await asyncio.wait([loop.run_in_executor(None, _do), asyncio.sleep(1)]) i += 1
async def blocking_call(loop: BaseEventLoop, page: str): if page == 'https://www.yahoo.com': time.sleep(5.0) if page == 'https://www.google.com': time.sleep(10.0) # NOTE: make requests.get non-blocking. i.e. part of the event loop. future = loop.run_in_executor( None, functools.partial(requests.get, page, timeout=10)) resp = await future logger.info('Received content from {}'.format(page)) return resp.url