Skip to content
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

Unify logging.handlers.SysLogHandler behavior with SocketHandlers #88457

Closed
cybergrind mannequin opened this issue Jun 2, 2021 · 6 comments
Closed

Unify logging.handlers.SysLogHandler behavior with SocketHandlers #88457

cybergrind mannequin opened this issue Jun 2, 2021 · 6 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@cybergrind
Copy link
Mannequin

cybergrind mannequin commented Jun 2, 2021

BPO 44291
Nosy @vsajip, @cybergrind
PRs
  • bpo-44291: Fix reconnection in logging.handlers.SysLogHandler (GH-26490) #26490
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-05.17:29:37.906>
    created_at = <Date 2021-06-02.18:31:52.216>
    labels = ['type-feature', 'library', '3.11']
    title = 'Unify logging.handlers.SysLogHandler behavior with SocketHandlers'
    updated_at = <Date 2021-08-05.17:29:37.906>
    user = 'https://github.com/cybergrind'

    bugs.python.org fields:

    activity = <Date 2021-08-05.17:29:37.906>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-05.17:29:37.906>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2021-06-02.18:31:52.216>
    creator = 'cybergrind'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44291
    keywords = ['patch']
    message_count = 6.0
    messages = ['394932', '394935', '394998', '394999', '395168', '399005']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'python-dev', 'cybergrind']
    pr_nums = ['26490']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44291'
    versions = ['Python 3.11']

    @cybergrind
    Copy link
    Mannequin Author

    cybergrind mannequin commented Jun 2, 2021

    Probably we should make the behavior of SysLogHandler consistent with other Socket handlers.

    Right now SocketHandler and DatagramHandler implement such behavior:

    1. on close set self.socket = None
    2. 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
    
    

    @cybergrind cybergrind mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 2, 2021
    @cybergrind
    Copy link
    Mannequin Author

    cybergrind mannequin commented Jun 2, 2021

    UPD: right now it has reconnection logic for unixsocket but not for tcp/udp

    @vsajip
    Copy link
    Member

    vsajip commented Jun 3, 2021

    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
    Copy link
    Mannequin Author

    cybergrind mannequin commented 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
    Copy link
    Member

    vsajip commented Jun 5, 2021

    Oh, sorry bad wording.

    OK, I see. Will take a look soon.

    it looks like we can refactor SysLogHandler to inherit from SocketHandler. Not sure if it should be done in this PR

    Better a separate PR for that, I feel.

    Removing the older Pythons from the issue, as this is an enhancement request.

    @vsajip vsajip removed 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes labels Jun 5, 2021
    @vsajip
    Copy link
    Member

    vsajip commented Aug 5, 2021

    New changeset 3d315c3 by Kirill Pinchuk in branch 'main':
    bpo-44291: Fix reconnection in logging.handlers.SysLogHandler (GH-26490)
    3d315c3

    @vsajip vsajip closed this as completed Aug 5, 2021
    @vsajip vsajip closed this as completed Aug 5, 2021
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant