python asyncio 协程池
# coding:utf-8 #当前的项目名:tmp_projects #当前编辑文件名:gventxiec #当前用户的登录名:ltl #当前系统日期时间:2021/5/25 13:38 #用于创建文件的IDE的名称: PyCharm import time import asyncio start=time.time() sem=asyncio.Semaphore(600) async def run(x,sem): async with sem: print(x) await asyncio.sleep(5) loop=asyncio.get_event_loop() sc=[asyncio.ensure_future(run(x,sem)) for x in range(1000)] loop.run_until_complete(asyncio.gather(*sc)) print(time.time()-start)