-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
GH-65046: Fix docs about logging in asyncio
#97559
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
Conversation
Doc/library/asyncio-dev.rst
Outdated
@@ -148,6 +148,10 @@ adjusted:: | |||
logging.getLogger("asyncio").setLevel(logging.WARNING) | |||
|
|||
|
|||
Network logging can block the event loop, it is recommended to use | |||
a separate thread for handling logs or use non blocking io. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be spelled non-blocking I/O
, but the bigger issue is that it’s not immediately clear what one should use: after all, we are in the async I/O docs! Is there a section in the os
module or another part of the stdlib that explains how to do non-asyncio non-blocking I/O?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, I don't think a comma is quite right here. I'll apply my suggestion and merge your PR.
Thanks @kumaraditya303 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry @kumaraditya303 and @gvanrossum, I had trouble checking out the |
GH-97581 is a backport of this pull request to the 3.10 branch. |
Explain that logging should not use network I/O. (cherry picked from commit d68c37c) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
No reaction to my remark about the vagueness of the new recommendation? |
I apologize, I was in "get things merged" mode and missed that. That said, I doubt we have something more specific than "use threads or write to disk" -- and while writing to disk is technically not perfect, it's generally considered good enough for asyncio (we've been told that there are async APIs for writing to disk on some platforms, and IIRC there are 3rd party packages that wrap them, but the benefits are at best marginal, and the code isn't portable. Also, I think the warning is about configuring a logger that uses network I/O rather than about how user code should do their own logging. The point is that asyncio itself sometimes calls the logging module and the user should avoid messing that up by accidentally configuring a network-using logger. User code can just use the run_in_executor API to do the logging from a thread, but we don't want to do that for asyncio's own logging. |
Thanks @kumaraditya303 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
GH-97582 is a backport of this pull request to the 3.11 branch. |
Explain that logging should not use network I/O. (cherry picked from commit d68c37c) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Closes #65046