Skip to content

Conversation

@kumaraditya303
Copy link
Contributor

@kumaraditya303kumaraditya303 commented Sep 26, 2022



Network logging can block the event loop, it is recommended to use
a separate thread for handling logs or use non blocking io.
Copy link
Member

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?

Copy link
Member

@gvanrossumgvanrossum left a 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.

@gvanrossumgvanrossum merged commit d68c37c into python:mainSep 26, 2022
@miss-islington
Copy link
Contributor

Thanks @kumaraditya303 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington
Copy link
Contributor

Sorry @kumaraditya303 and @gvanrossum, I had trouble checking out the 3.11 backport branch.
Please backport using cherry_picker on command line.
cherry_picker d68c37c0d08542a346a13b150a204208bb0408f5 3.11

@bedevere-botbedevere-bot removed the needs backport to 3.10 only security fixes label Sep 26, 2022
@bedevere-bot
Copy link

GH-97581 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 26, 2022
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>
@merwok
Copy link
Member

No reaction to my remark about the vagueness of the new recommendation?

@gvanrossum
Copy link
Member

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.

@gvanrossumgvanrossum removed the needs backport to 3.11 only security fixes label Sep 26, 2022
@gvanrossumgvanrossum added the needs backport to 3.11 only security fixes label Sep 26, 2022
@miss-islington
Copy link
Contributor

Thanks @kumaraditya303 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-97582 is a backport of this pull request to the 3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11 only security fixes label Sep 26, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 26, 2022
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>
miss-islington added a commit that referenced this pull request Sep 26, 2022
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>
miss-islington added a commit that referenced this pull request Sep 26, 2022
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>
@kumaraditya303kumaraditya303 deleted the asyncio-docs branch September 27, 2022 10:50
pablogsal pushed a commit that referenced this pull request Oct 22, 2022
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>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip newstopic-asyncio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

asyncio docs should call out that network logging is a no-no

5 participants

@kumaraditya303@miss-islington@bedevere-bot@merwok@gvanrossum