- 論壇徽章:
- 2
|
本人python小白,最近在用eventlet 中的wsgi實(shí)現(xiàn)http restful接口。測試時發(fā)現(xiàn)如果一個請求阻塞了,所以請求都會等待。
請問是否可以實(shí)現(xiàn)并行處理請求,或者有沒有好的框架推薦?
目的和要求如下:
1.想實(shí)現(xiàn)一個http server,提供restful調(diào)用接口。
2.提供的接口是同步的。
3.如何實(shí)現(xiàn)并行處理請求?
我自己是如下實(shí)現(xiàn)的,不對,哪位大俠幫忙改正一下。- def handler(env, start_response):
- try :
- request = requestUtil.Request(env)
- returnv = pool.spawn(myHandler, request)
- print returnv
- except Exception :
- log.error("Dispatcher Exception.")
- print "Dispatcher Exception."
- start_response('200 OK', [('Content-Type', 'text/plain')])
- return [returnv]
- if __name__ == "__main__" :
- pool = eventlet.GreenPool()
- port = 8023
- wsgi.server(eventlet.listen(('', port)), handler)
復(fù)制代碼 上面的實(shí)現(xiàn)雖然處理了請求,但是并沒有給調(diào)用者返回。高手幫幫忙 |
|