1. 程式人生 > >Python asyncio/aiohttp: ValueError: too many file descriptors in select() on Windows

Python asyncio/aiohttp: ValueError: too many file descriptors in select() on Windows

錯誤描述

下面是我的部分程式碼:

tasks = [asyncio.ensure_future(run(url)) for url in url_list]
loop.run_until_complete(asyncio.wait(tasks))

下面是錯誤:

ValueError: too many file descriptors in select()。

分析

By default Windows can use only 64 sockets in asyncio loop. This is a limitation of underlying select() API call.

在Windows下,假如你的併發達到64個,程式會報錯,這是受限於select()這個API的。