更新时间:2022-06-27 00:21:05
我认为没有错误.
烧瓶可能正在捕获所有异常,以便不停止主进程为应用程序提供服务.
As flask is probably catching all exceptions in order to do not stop the main process from serving the application.
正如您提到的,使用os._exit(0)即可完成工作.
As you mention, using os._exit(0) does the work.
据我所知,它被python2.7/SocketServer.py捕获:
As far as I've seen, it's catched by python2.7/SocketServer.py:
598 try:
599 self.finish_request(request, client_address)
600 self.shutdown_request(request)
601 except:
602 self.handle_error(request, client_address)
603 self.shutdown_request(request)
基本上可以捕获所有内容,但可以处理错误.
Which basically catches everything but handles an error.
顺便说一句:我是唯一一个认为可以通过try/except/finally进行重构的人吗?
BTW: Am I the only one who thinks that this could be refactored with a try/except/finally?