我使用pythons的pathcio模块来运行并发网络请求.
async def fetch(url, max_pages):
async with aiohttp.ClientSession() as session:
tasks = [get_html(session, f"{url}/{i}/") for i in range(1, max_pages + 1)]
await asyncio.gather(*tasks) #this function exits before all respose arrives.
loop = asyncio.get_event_loop()
loop.run_until_complete(fetch(url, max_pages))
我的代码中有什么错误?
我期待着完成所有的任务.