Issue 25139: socketserver.ThreadingMixIn exception handler: Just a little refactoring (original) (raw)
Issue25139
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) * ![]() |
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) * ![]() |
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) * ![]() |
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:21 | admin | set | github: 69326 |
2016-02-21 11:25:51 | martin.panter | set | status: open -> closedsuperseder: socketserver.BaseServer.handle_error() should not catch exiting exceptionsmessages: + resolution: out of datestage: patch review -> resolved |
2015-09-19 06:47:13 | martin.panter | set | nosy: + martin.pantermessages: + title: Just a little refactoring -> socketserver.ThreadingMixIn exception handler: Just a little refactoring |
2015-09-18 23:35:44 | terry.reedy | set | nosy: + terry.reedymessages: + |
2015-09-16 17:58:31 | berker.peksag | set | nosy: + berker.peksag |
2015-09-16 17:57:35 | berker.peksag | set | stage: patch reviewversions: + Python 3.6, - Python 3.5 |
2015-09-16 09:26:03 | Алексей Смирнов | create |