tornado流程分析
2015-12-01 15:36:03 4 举报
tornado工作流程分析。
作者其他创作
大纲/内容
class http1connection
以accept_handler作为回调调用
add_handler()
_server_request_loop
handle_stream()
将_ServerRequestAdapter为参数调用
add_accept_handler()
调用
accept_handler()
当read事件发生时,accept_handler被调用,进而HTTPServer的_handle_connection()被调用。接着handle_stream()被调用
class Application
__init__
调用并得到一个_RequestDispatcher对象
httpserver.py
add_sockets()
回调start_request方法并得到一个_ServerRequestAdapter对象
bind_sockets()创建、绑定、监听socket
class RequestHandler
在此函数内部会调用_handle_connection()
_execute()会根据url请求的类型调用对应的handler中的某一种方法,比如get或post。
class _RequestDispatcher
headers_received()
execute()
start_request()
class _ServerRequestAdapter
实例化
接着调用其start_serving()方法
read_response()
_read_message()
start_serving
ioloop.py
先初始化此对象
class IOLoop
调用自己的start_request方法
class HTTPServer
netutil.py
得到http1connection对象
http1connection.py
listen()
_execute()
request_callback变量(Application对象)
以_handle_connection()作为回调
web.py
headers_received
_handle_connection()
得到_RequestDispatcher对象
start_request
class HTTP1ServerConnection
收藏
0 条评论
下一页