AsyncClient() blocked event loop #3707
Unanswered
ClericPy
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
AsyncClient()itself is a synchronous function. Placing it inside anasync defcoroutine will block the main thread's event loop — you can see a warning by enabling asyncio's debug mode.Currently, this problem is solved in two ways: either using
asyncio.to_threadto avoid blocking during lazy initialization, or sharing the object after it has been asynchronously initialized.Should there be an official, native solution to non-blockingly initialize it within an
async defcoroutine using the syntaxasync with AsyncClient() as client:?Beta Was this translation helpful? Give feedback.
All reactions