This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socketserver.ThreadingMixIn exception handler: Just a little refactoring
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: out of date
Dependencies: Superseder: socketserver.BaseServer.handle_error() should not catch exiting exceptions
View: 23430
Assigned To: Nosy List: berker.peksag, martin.panter, terry.reedy, Алексей Смирнов
Priority: normal Keywords:

Created on 2015-09-16 09:26 by Алексей Смирнов, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Repositories containing patches
https://hg.python.org/cpython/file/tip/Lib/socketserver.py#l627
Messages (4)
msg250833 - (view) Author: Алексей Смирнов (Алексей Смирнов) Date: 2015-09-16 09:26
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)
msg251042 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-09-18 23:35
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
msg251058 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-09-19 06:47
I suggest changing the “except” clause to “except BaseException”, which would make the intention clearer.

As an alternative, see also my Issue 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)
msg260608 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-02-21 11:25
I pushed the above code to 3.6, so closing this.
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69326
2016-02-21 11:25:51martin.pantersetstatus: open -> closed
superseder: socketserver.BaseServer.handle_error() should not catch exiting exceptions
messages: + msg260608

resolution: out of date
stage: patch review -> resolved
2015-09-19 06:47:13martin.pantersetnosy: + martin.panter

messages: + msg251058
title: Just a little refactoring -> socketserver.ThreadingMixIn exception handler: Just a little refactoring
2015-09-18 23:35:44terry.reedysetnosy: + terry.reedy
messages: + msg251042
2015-09-16 17:58:31berker.peksagsetnosy: + berker.peksag
2015-09-16 17:57:35berker.peksagsetstage: patch review
versions: + Python 3.6, - Python 3.5
2015-09-16 09:26:03Алексей Смирновcreate