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

socketserver.ThreadingMixIn exception handler: Just a little refactoring #69326

Closed
ghost opened this issue Sep 16, 2015 · 4 comments
Closed

socketserver.ThreadingMixIn exception handler: Just a little refactoring #69326

ghost opened this issue Sep 16, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ghost
Copy link

ghost commented Sep 16, 2015

BPO 25139
Nosy @terryjreedy, @berkerpeksag, @vadmium
Superseder
  • bpo-23430: socketserver.BaseServer.handle_error() should not catch exiting exceptions
  • 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 2016-02-21.11:25:51.690>
    created_at = <Date 2015-09-16.09:26:03.510>
    labels = ['type-feature', 'library']
    title = 'socketserver.ThreadingMixIn exception handler: Just a little refactoring'
    updated_at = <Date 2016-02-21.11:25:51.688>
    user = None

    bugs.python.org fields:

    activity = <Date 2016-02-21.11:25:51.688>
    actor = 'martin.panter'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-02-21.11:25:51.690>
    closer = 'martin.panter'
    components = ['Library (Lib)']
    creation = <Date 2015-09-16.09:26:03.510>
    creator = '\xd0\x90\xd0\xbb\xd0\xb5\xd0\xba\xd1\x81\xd0\xb5\xd0\xb9 \xd0\xa1\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbd\xd0\xbe\xd0\xb2'
    dependencies = []
    files = []
    hgrepos = ['317']
    issue_num = 25139
    keywords = []
    message_count = 4.0
    messages = ['250833', '251042', '251058', '260608']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'berker.peksag', 'martin.panter', '\xd0\x90\xd0\xbb\xd0\xb5\xd0\xba\xd1\x81\xd0\xb5\xd0\xb9 \xd0\xa1\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbd\xd0\xbe\xd0\xb2']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = '23430'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25139'
    versions = ['Python 3.6']

    @ghost
    Copy link
    Author

    ghost commented Sep 16, 2015

    https://github.com/python/cpython/blob/3.5/Lib/socketserver.py#L627
    Must be:
    try:
    self.finish_request(request, client_address)
    except:
    self.handle_error(request, client_address)
    finally:
    self.shutdown_request(request)

    Repository owner added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 16, 2015
    @terryjreedy
    Copy link
    Member

    I believe this is equivalent.

    In general, bare excepts should be either made more specific or commented as intentional. Since derived classes can override finish_request, and fail any which way, the latter is probably appropriate here:
    # derived classes may override finish_request

    @vadmium
    Copy link
    Member

    vadmium commented Sep 19, 2015

    I suggest changing the “except” clause to “except BaseException”, which would make the intention clearer.

    As an alternative, see also my bpo-23430, were I proposed not catching exceptions like KeyboardInterrupt and SystemExit, by changing this to:

    try:
    self.finish_request(request, client_address)
    except Exception:
    self.handle_error(request, client_address)
    finally:
    self.shutdown_request(request)

    @vadmium vadmium changed the title Just a little refactoring socketserver.ThreadingMixIn exception handler: Just a little refactoring Sep 19, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Feb 21, 2016

    I pushed the above code to 3.6, so closing this.

    @vadmium vadmium closed this as completed Feb 21, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants