我从一个简单的Python 2.5
应用程序引擎应用程序开始并将其迁移到Python 2.7
希望利用其多线程功能。迁移后,我注意到webapp2.RequestHandler
所有实例都是从Main Thread调用的。
我有一个AJAX
客户端触发多个异步请求。我只想在服务器端发生某些事件时才响应的请求之一。假设事件现在休眠 10 秒。问题是睡眠发生在主线程中并在处理我的第二个 ASYNC 请求之前占用线程AJAX
。我错过了什么?
这是一个堆栈跟踪:
PyDevDebug [PyDev Google App Run] dev_appserver.py
MainThread - pid4276_seq4
post [test1.py:53]
dispatch [webapp2.py:570]
call [webapp2.py:1102]
default_dispatcher [webapp2.py:1278]
call [webapp2.py :1529]
处理 [wsgi.py:223]
HandleRequest [wsgi.py:298] HandleRequest [runtime.py:151]
ExecutePy27Handler [dev_appserver.py:1525]
ExecuteCGI [dev_appserver.py:1701]
调度 [dev_appserver.py:1803 ]
调度 [dev_appserver.py:719] _调度 [dev_appserver.py:2870]
_HandleRequest [dev_appserver.py:3001]
do_POST [dev_appserver.py:2794] handle_one_request [BaseHTTPServer.py:328]
处理 [BaseHTTPServer.py:340]
init [SocketServer.py:638]
init [dev_appserver.py:2780]
finish_request [ SocketServer.py:323]
process_request [SocketServer.py:310]
_handle_request_noblock [SocketServer.py:284]
handle_request [dev_appserver.py:3991]
serve_forever [dev_appserver.py:4028]
main [dev_appserver_main.py:721]
[dev_appserver_main.py :747]
run_file [dev_appserver.py:167] [dev_appserver.py:171] 运行 [pydevd.py:1090]
[pydevd.py:1397]
线程 4 - pid4276_seq5 dev_appserver.py