Unexpected asyncio.CancelledError #2792
-
First off, thanks for making this library, it's very useful. There appears a rare condition where on issuing an asynchronous web request, an We are issuing a large number of web requests (in the millions), so while I haven't been able to reproduce this in isolation, I was able to capture a traceback from our production logs:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hey! Thanks for opening a discussion. Is there anywhere in your code that could be starting cancellation? Asynchronous cancellation fires on the first unshielded |
Beta Was this translation helpful? Give feedback.
-
Okay!!! I was able to reliably reproduce the import httpx
import random
import asyncio
## STEP 1:
## python -m http.server 5555
async def main():
async def request():
transport = httpx.AsyncHTTPTransport(retries=5) # <-----------------------
async with httpx.AsyncClient(transport=transport, timeout=random.random() / 10) as client:
try:
return await client.get("http://127.0.0.1:5555")
except httpx.TimeoutException:
print("_", end="", flush=True)
while 1:
tasks = [asyncio.create_task(request()) for _ in range(100)]
await asyncio.gather(*tasks)
asyncio.run(main()) |
Beta Was this translation helpful? Give feedback.
-
Aaaaaaaaand.....it's no longer reproducible with |
Beta Was this translation helpful? Give feedback.
Aaaaaaaaand.....it's no longer reproducible with
anyio==4.0.0rc1
. Thanks folks! It's been lovely talking to you all!