You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unify logging.handlers.SysLogHandler behavior with SocketHandlers #88457
Probably we should make the behavior of SysLogHandler consistent with other Socket handlers.
Right now SocketHandler and DatagramHandler implement such behavior:
on close set self.socket = None
when trying to send - make socket when it is None
SysLogHandler doesn't implement this behavior and when you close the socket for some reason (eg. restart of uWSGI server on code change) it leaves it in the closed state, then raises an error when you try to send any message because it is closed
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.9/logging/handlers.py", line 959, in emit
self.socket.sendto(msg, self.address)
OSError: [Errno 9] Bad file descriptor
right now it has reconnection logic for unixsocket but not for tcp/udp
Should it not have UDP/TCP supported as well as domain sockets, before being reviewed?
cybergrind commented on Jun 3, 2021
cybergrindmannequin
MannequinAuthor
More actions
Oh, sorry bad wording.
The current implementation has reconnection logic only for UNIX sockets
The patch adds reconnection logic for UDP/TCP sockets as well.
I've done it with minimal changes to the existing code to accomplish that. And probably it can be merged.
But in general, it looks like we can refactor SysLogHandler to inherit from SocketHandler. Not sure if it should be done in this PR or better to create separate?
Activity
cybergrind commentedon Jun 2, 2021
Probably we should make the behavior of SysLogHandler consistent with other Socket handlers.
Right now SocketHandler and DatagramHandler implement such behavior:
closesetself.socket = NoneSysLogHandler doesn't implement this behavior and when you close the socket for some reason (eg. restart of uWSGI server on code change) it leaves it in the closed state, then raises an error when you try to send any message because it is closed
1 remaining item
vsajip commentedon Jun 3, 2021
Should it not have UDP/TCP supported as well as domain sockets, before being reviewed?
cybergrind commentedon Jun 3, 2021
Oh, sorry bad wording.
The current implementation has reconnection logic only for UNIX sockets
The patch adds reconnection logic for UDP/TCP sockets as well.
I've done it with minimal changes to the existing code to accomplish that. And probably it can be merged.
But in general, it looks like we can refactor SysLogHandler to inherit from SocketHandler. Not sure if it should be done in this PR or better to create separate?
vsajip commentedon Jun 5, 2021
OK, I see. Will take a look soon.
Better a separate PR for that, I feel.
Removing the older Pythons from the issue, as this is an enhancement request.
vsajip commentedon Aug 5, 2021
New changeset 3d315c3 by Kirill Pinchuk in branch 'main':
bpo-44291: Fix reconnection in logging.handlers.SysLogHandler (GH-26490)
3d315c3