Skip to content

Instantly share code, notes, and snippets.

@victoraugustolls
Created March 2, 2020 15:17
Show Gist options
  • Save victoraugustolls/01002ae218366b453e962446c9c8a274 to your computer and use it in GitHub Desktop.
Save victoraugustolls/01002ae218366b453e962446c9c8a274 to your computer and use it in GitHub Desktop.
import asyncio
import httpx
async def do_request(client: httpx.AsyncClient):
try:
await client.get(
url="https://google.com",
)
except Exception as e:
print(f"{type(e)}: {str(e)}")
async def request_multiple(client: httpx.AsyncClient):
count = 0
while True:
print(f"Request number: {count}")
await asyncio.gather(
do_request(client=client),
do_request(client=client),
do_request(client=client),
do_request(client=client),
do_request(client=client)
)
count += 5
if __name__ == "__main__":
cl = httpx.AsyncClient()
asyncio.run(request_multiple(client=cl))
@victoraugustolls
Copy link
Author

With http2 disabled:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment