Python 中 tornado 使用协程
- from tornado.web import asynchronous
- from tornado.concurrent import run_on_executor
- from concurrent.futures import ThreadPoolExecutor
-
- class xxx
- executor = ThreadPoolExecutor(10)
-
- @delete(_path=r"/xxx/{id}", _produces=mediatypes.APPLICATION_JSON)
- @asynchronous
- @gen.coroutine
- def delete_much_things(self,id):
- yield do_delete(id)
-
- @run_on_executor
- def do_delete(self,id):
- pass