天天看點

asyncio aiohttp aiomysql用法

簡單記錄一下,自己在異步協程跟異步存儲中碰到的一些坑

first

# 設定并發數  注意:此處并發經測試不能低于tasks裡面的數量
        self.sem_info = asyncio.Semaphore(1)
        
        async with self.sem_info:
        await asyncio.gather(*[self._download(i) for i in range(67)])

           

second

async with self.connect.acquire() as conn:
        mysql異步存儲時,防止資料插入有未知的錯誤

           

)