Skip to content

RuntimeError: The connection pool was closed while 1 HTTP requests/responses were still in-flight. #2138

Answered by guyskk
guyskk asked this question in Potential Issue
Discussion options

You must be logged in to vote

I got the reason: asyncio.gather will not cancel task1 when task2 timeout, so task1 is pending when AsyncClient close. And task1 seems cancelled by asyncio loop or GC when asyncio.run ending.

https://docs.python.org/3/library/asyncio-task.html#asyncio.gather
Other awaitables in the aws sequence won’t be cancelled and will continue to run.

The solution is manually cancel task1 before AsyncClient close.

Replies: 1 comment

Comment options

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