What is the default concurrency level with asyncio in Python?

Viewed 613

I'm using Python Asyncio to do a lot of HTTP requests.

I'm wondering what is the default concurrency level of Asyncio or how many HTTP requests would be happening in parallel at any given time?

The code I'm using to do the HTTP requests you can find below:

async def call_url(self, session, url):
    response = await session.request(method='GET', url=url)
    return response


async def main(self, url_list):
    async with aiohttp.ClientSession() as session:
        res = await asyncio.gather(*[self.call_url(session, url) for url in url_list])
        return res
1 Answers

There is no built-in limit in asyncio, but there is one in aiohttp. The TCPConnector limits the number of connections to 100 by default. You can override it by creating a TCPConnector with a different limit and passing it to the session.

Related