flask-source-run

run

  • The following figure shows the execution process when flask executes app.run(), and the execution flow of __call__ when a request is received. For the execution process of flask's request, please refer to https://blog.csdn.net/DALAOS/ article/details/113566518 request execution process
  • If you understand that there is a discrepancy, you can privately trust me to discuss the correct process
app run_simple() SharedDataMiddleware inner() BaseWSGIServer run run_simple(host, port, self, **options) SharedDataMiddleware(application, static_files) 返回application<SharedDataMiddleware obj> 执行inner() make_server make_server 返回一个srv<BaseWSGIServer> srv.serve_forever() srv.serve_forever() HTTPServer.serve_forever(self) make_server while not self.__shutdown_request 循环监听 如果当前我收到请求转发流程为 self._handle_request_noblock() self.process_request(request, client_address) self.finish_request(request, client_address) 猜测WSGIRequestHandler类 继承自BaseHTTPRequestHandler 可能实现了__call__方法HTTPServer self.RequestHandlerClass(request, client_address, self) <WSGIRequestHandler> loop [make_server] 执行__call__ 执行__call__ app run_simple() SharedDataMiddleware inner() BaseWSGIServer

Guess you like

Origin blog.csdn.net/DALAOS/article/details/113695691