-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-126400: Add TCP socket timeout to SysLogHandler to prevent blocking #126716
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
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Thank you for the PR. Would you mind updating the documentation, adding a NEWS entry using the |
Hi @vsajip, added |
Thanks for those. You don't feel comfortable updating the docs? |
@vsajip Oh, I thought you meant only the blurb. I'll update the documentation as well |
Hopefully the first of many contributions! As it's an API change, it needs the documentation updating so users will know about the new parameter. |
@@ -0,0 +1,3 @@ | |||
Added a timeout parameter to logging.handlers.SysLogHandler class to control the TCP socket timeout and prevent process blocking when the Syslog server is unreachable; this improves resilience when working with unresponsive Syslog servers. |
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.
Added a timeout parameter to logging.handlers.SysLogHandler class to control the TCP socket timeout and prevent process blocking when the Syslog server is unreachable; this improves resilience when working with unresponsive Syslog servers. | |
Added a timeout parameter to :class:`logging.handlers.SysLogHandler` class to control the TCP socket timeout and prevent process blocking when the Syslog server is unreachable; this improves resilience when working with unresponsive Syslog servers. | |
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.
Please update file ./Doc/library/logging.handlers.rst
to mention added timeout
parameter.
Take a look atsocktype
argument for inspiration.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
bffa2ed
to
73e6f80
Compare
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
The docs build is failing with some unrelated error in processing the Misc/NEWS entries, same happens locally. I've fixed the sphinx lint error and missing blurb in this PR. Not sure what the docs build problem is. |
Somewhere, perhaps during a force-push, the original blurb got lost. I added a new one (a bit shorter) and everything now seems to be building correctly. I had to update a couple of unrelated blurb files, seemingly because they wrongly had |
…locking (pythonGH-126716) Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Issue #126400.
branch name - fix-issue-126400
Summary
In the current implementation of the
SysLogHandler
class from thelogging.handlers
module, if the specified address does not respond or is unreachable, thecreateSocket
method may block indefinitely in case of using TCP socket (based on stream). This is problematic because there is no way to set a socket timeout during the connection's creation without overriding the entirecreateSocket
method.Changes
timeout
parameter to theSysLogHandler.__init__
method, allowing users to specify a timeout for the socket connection.createSocket
method to apply thetimeout
to the socket if provided.This change allows users to prevent indefinite blocking on socket creation, enabling more robust error handling when the SysLog server is unresponsive.
Example Usage
With this update, users can now create a
SysLogHandler
with a timeout as follows: