Skip to content
Discussion options

You must be logged in to vote

When reusing the client side, the gap between the two is small.

Test Results:

-> aiohttp AsyncClient 0.78 s
-> httpx AsyncClient 0.81 s

Test Script:

import asyncio

import aiohttp
import httpx


async def ah(client):
    await client.get("https://www.google.com/generate_204")


async def aio(client):
    async with client.get("https://www.google.com/generate_204") as resp:
        await resp.text()


async def mutli_ah():
    async with httpx.AsyncClient(timeout=3600) as client:
        stime = asyncio.get_event_loop().time()
        tasks = [ah(client) for _ in range(100)]
        await asyncio.gather(*tasks)
        print("httpx AsyncClient", asyncio.get_event_loop().time() - stime, "s")…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brianler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant