-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio.getaddrinfo
manifests in misleading DNS timeouts when thread pool executor is saturated
#112169
Comments
Thanks for the report! I believe the reasons why we do it this way are as valid as they were in 2015 — Python has no async DNS API, only a synchronous one. I agree that the executor thing ought to be documented. We could also possibly use a separate executor. Can you submit a PR for a doc update? The other thing needs a little more thought as e.g. how do we control the capacity of that executor. Your app could also use its own custom executor, of course — it’s worth mentioning that in the docs update. |
…e implications.
…sage and implications. (#112191) Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…utor usage and implications. (pythonGH-112191) (cherry picked from commit fc297b4) Co-authored-by: Alek Kowalczyk <alek.kowalczyk@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…utor usage and implications. (pythonGH-112191) (cherry picked from commit fc297b4) Co-authored-by: Alek Kowalczyk <alek.kowalczyk@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…cutor usage and implications. (GH-112191) (#120936) gh-112169: Documented getaddrinfo/getnameinfo default loop executor usage and implications. (GH-112191) (cherry picked from commit fc297b4) Co-authored-by: Alek Kowalczyk <alek.kowalczyk@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…cutor usage and implications. (GH-112191) (#120935) gh-112169: Documented getaddrinfo/getnameinfo default loop executor usage and implications. (GH-112191) (cherry picked from commit fc297b4) Co-authored-by: Alek Kowalczyk <alek.kowalczyk@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…utor usage and implications. (python#112191) Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…utor usage and implications. (python#112191) Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
…utor usage and implications. (python#112191) Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Bug report
Bug description:
There is no mention in https://docs.python.org/3/library/asyncio-eventloop.html#dns that
asyncio.getaddrinfo
is just a ThreadPoolExecutor-based wrapper around sync getaddrinfo (base_events.py:860 - BaseEventLoop.getaddrinfo)This can lead to mysterious "DNS timeouts" or CancelledErrors during DNS resolution if the executor pool is saturated by other, often totally unrelated code, which is especially not uncommon for any app using asgiref's
@sync_to_async
decorator.At the minimum, until this function is converted to real async (if feasible), it would be nice if documentation warned about using shared thread pool executor.
Sample stack trace from httpcore => anyio, which uses asyncio.getaddrinfo under the hood, when the thread pool is saturated:
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: