async def readCommentsFromLogger(request): data = [] async with aiofile.AIOFile("verifier_logger.csv", 'r') as afp: async for line in aiofile.LineReader(afp): row = line.split(",") data.append({"timestamp": row[0], "comment": row[1].strip("\n")}) return web.json_response({"logs": data})
async def asynchronous(name_file): async with aiofile.async_open(name_file, 'r') as ai_as_o: # открываем файл urls.txt async for line in aiofile.LineReader( ai_as_o): # считываем веб-ссылки построчно async with aiohttp.ClientSession() as client: asyncio.ensure_future(fetch(client, line)) print('done')
async def seeker(file): async with aiofile.AIOFile(file, 'r') as urls: texts = [] async for url in aiofile.LineReader(urls): texts.append(fetch(url)) await asyncio.gather(*texts)
async def async_read(file_name): async with aiofile.AIOFile(file_name, 'r') as f: async with aiohttp.ClientSession() as session: async for line in aiofile.LineReader(f): await asyncio.ensure_future(fetch(session, line))