
\u4e00\u4e2a\u5927\u6587\u4ef6
\n\u6211\u5728 client \u901a\u8fc7 requests \u5e93\u6765\u8fdb\u884c\u4f20\u8f93
with open(path_file, \"rb\") as f:\n res = requests.post(url, data=f, timeout=600)\n\n\u6211\u5728 server \u7aef\uff0c\u4ece tornado_request \u4e2d\u8be5\u5982\u4f55\u63a5\u6536\u8fd9\u4e2a\u6587\u4ef6\u6d41\u5e76\u4fdd\u5b58\u4e0b\u6765\u5462\u3002
\n\u8c22\u8c22\u5404\u4f4d\u7684\u4e0d\u541d\u8d50\u6559\u3002
\u770b\u5f97\u6559\u7a0b\u4e00\u5934\u96fe\u6c34, \u53ea\u80fd\u7406\u89e3\u90a3\u4e2a\u81ea\u5e26\u7684 http \u8bf7\u6c42, \u770b\u4e86\u5f88\u4e45\u4e5f\u6ca1\u770b\u5230\u6709\u6bd4\u5982\u6570\u636e\u5e93\u67e5\u8be2, \u6587\u4ef6\u5904\u7406\u4ec0\u4e48\u7684\u5176\u4ed6\u4f8b\u5b50, \u540e\u6765\u53bb\u770b\u770b\u5176\u4ed6\u6559\u7a0b, \u5b9e\u73b0\u5012\u7b97\u662f\u52c9\u5f3a\u5b9e\u73b0\u4e86, \u4f46\u611f\u89c9\u4e5f\u592a\u590d\u6742\u4e86\u5427? ?
\n\u5c31\u6bd4\u5982\u4f8b\u5b50\u4e2d\u7684\u6211\u5047\u8bbe\u6709\u4e2a\u957f\u8017\u65f6\u7684\u4efb\u52a1, \u600e\u4e48\u5199\u624d\u4f1a\u7b80\u5355\u70b9?
\n\nimport tornado.ioloop\nimport tornado.web\nimport time\nimport _thread\n\n\n# \u6a21\u62df\u8017\u65f6\u4efb\u52a1\ndef long_work(arg):\n time.sleep(5)\n yield arg * 1024\n\n\ndef mycoroutine(func):\n def wrapper(self):\n gen = func(self)\n work_gen = next(gen)\n def fun():\n result = next(work_gen)\n try:\n \tgen.send(result)\n except StopIteration:\n \tpass\n _thread.start_new_thread(fun, ())\n return wrapper\n\n\nclass IndexHandler(tornado.web.RequestHandler):\n @tornado.web.asynchronous\n @mycoroutine\n def get(self):\n arg = 10 # \u5047\u8bbe\u8bf7\u6c42\u7684\u53c2\u6570\n result = yield long_work(arg)\n self.finish(f'<h1>Index {result}</h1>')\n\n\nclass SyncHandler(tornado.web.RequestHandler):\n def get(self):\n \tself.write('<h1>SyncHandler</h1>')\n\n\ndef make_app():\n return tornado.web.Application([\n (r'/', IndexHandler),\n (r'/sync', SyncHandler)\n ])\n\n\nif __name__ == '__main__':\n app = make_app()\n app.listen(8888)\n tornado.ioloop.IOLoop.current().start()\n \n\n" }, { "author": { "url": "member/aoscici2000", "name": "aoscici2000", "avatar": "https://cdn.v2ex.com/gravatar/45fecfe863567980c5951ddd8b633a8c?s=73&d=retro" }, "url": "t/514006", "title": "tornado \u4e0b ckeditor \u56fe\u7247\u4e0a\u4f20\u95ee\u9898", "id": "t/514006", "date_published": "2018-12-03T14:58:02+00:00", "content_html": "\u6309\u7f51\u4e0a\u7684\u65b9\u6cd5\u66f4\u6539\u4e86\u914d\u7f6e\u540e,\u5355\u7eaf\u672c\u5730\u6253\u5f00 html \u6587\u4ef6\u662f\u663e\u793a\u6709\u56fe\u7247\u4e0a\u4f20\u7684\u9009\u9879\u7684, \u4f46\u670d\u52a1\u8dd1\u8d77\u6765\u7684\u65b9\u5f0f\u6253\u5f00\u7684\u8bdd, \u5c31\u6ca1\u6709\u4e86, \u8fd9\u662f\u600e\u4e48\u56de\u4e8b??
\n" }, { "author": { "url": "member/aoscici2000", "name": "aoscici2000", "avatar": "https://cdn.v2ex.com/gravatar/45fecfe863567980c5951ddd8b633a8c?s=73&d=retro" }, "url": "t/513504", "title": "Tornado \u5f02\u6b65\u600e\u4e48\u5199\u7684?", "id": "t/513504", "date_published": "2018-12-02T04:22:59+00:00", "content_html": "\u6bd4\u5982\u8bf4\u8981\u7b49\u67d0\u4e2a\u8017\u65f6\u64cd\u4f5c\u7684\u7ed3\u679c, \u8be5\u600e\u4e48\u5199?
\n\u7f51\u4e0a\u770b\u4e86\u534a\u5929\u4f8b\u5b50, \u7167\u7740\u505a\u4e86\u505a, \u8c8c\u4f3c\u884c\u4e0d\u901a
\nclass AsyncTaskHandler(tornado.web.RequestHandler):
\n@tornado.web.asynchronous\n@tornado.gen.coroutine\ndef get(self, *args, **kwargs):\n resp = yield tornado.gen.Task(self.do_something)\n self.finish(resp)\n\n@tornado.gen.coroutine\ndef do_something(self, *args, **kwargs):\n time.sleep(10)\n return {'message': 'OKOK'}\n\n" }, { "author": { "url": "member/kidlfy", "name": "kidlfy", "avatar": "https://cdn.v2ex.com/avatar/3e87/2256/347016_large.png?m=1536907363" }, "url": "t/512202", "title": "tornado \u600e\u4e48\u80fd\u786e\u4fdd\u7aef\u53e3\u6302\u4e86 \u670d\u52a1\u4e5f\u4e0d\u4f1a\u505c\u6b62\uff1f", "id": "t/512202", "date_published": "2018-11-28T02:00:59+00:00", "content_html": "\u5c0f\u767d python\ntornado \u4e5f\u4e0d\u719f \u521a\u8bd5\u7740\u7528\n\u9700\u8981\u914d\u7f6e\u4e24\u4e2a\u7aef\u53e3\u6765\u4fdd\u8bc1 \u4e00\u4e2a\u7aef\u53e3\u6302\u4e86\u53e6\u4e00\u4e2a\u4f1a\u8d77\u6765 \u670d\u52a1\u4e0d\u4f1a\u7ec8\u6b62\n\u901a\u8fc7 nginx \u8981\u600e\u4e48\u914d\u7f6e\uff1f\n\u8981\u54ed\u4e86\n\u4e0d\u4f1a\u505a\n\u5f88\u5c34\u5c2c
\n" }, { "author": { "url": "member/everlasting_188", "name": "everlasting_188", "avatar": "https://cdn.v2ex.com/gravatar/810276494571f641863966d535c74c9a?s=73&d=retro" }, "url": "t/467856", "date_modified": "2018-07-03T14:46:57+00:00", "content_html": "", "date_published": "2018-07-03T09:51:59+00:00", "title": "Tornado \u8def\u7531\u6709\u4ec0\u4e48\u597d\u65b9\u6cd5\uff0c\u4e00\u4e2a\u4e00\u4e2a\u5199\u592a\u9ebb\u70e6\u4e86\uff0c\u6709\u6ca1\u6709\u6839\u636e url \u548c\u6ce8\u89e3\u5339\u914d\u7684\u65b9\u6cd5\u5462", "id": "t/467856" }, { "author": { "url": "member/mywaiting", "name": "mywaiting", "avatar": "https://cdn.v2ex.com/avatar/4f87/658e/1340_large.png?m=1733248338" }, "url": "t/350765", "date_modified": "2017-03-27T16:35:11+00:00", "content_html": "\u8bb0\u5f97\u5148\u524d\u6709\u4e2a issue \u63d0\u53ca\u5230 routing \u7684\u95ee\u9898\u7684\uff0c\u6df1\u591c\u7ffb\u4e00\u4e0b Tornado \u7684\u4ee3\u7801\uff0c\u521a\u521a\u597d\u9047\u4e0a update \u5230 v4.5\r\u662f\u4e0d\u662f\u5c31\u4e0d\u7528\u589e\u52a0 XSRF \u7684\u652f\u6301\u4e86\uff0c\u6bd5\u7adf\u8fd9\u4e2a\u8fd8\u662f\u7528\u6765\u5904\u7406 cookie \u7684\u3002
\n" }, { "author": { "url": "member/burnex", "name": "burnex", "avatar": "https://cdn.v2ex.com/avatar/dbe3/bcfb/37711_large.png?m=1393683848" }, "url": "t/321411", "title": "tornado \u4f18\u79c0\u9879\u76ee\u63a8\u8350", "id": "t/321411", "date_published": "2016-11-18T02:58:16+00:00", "content_html": "\u6253\u7b97\u597d\u597d\u5b66\u4e60\u4e0b tornado \uff0c\u8bf7\u5927\u5bb6\u63a8\u8350\u4e00\u4e9b\u597d\u7684 tornado \u9879\u76ee\uff0c\u8c22\u8c22
\n" }, { "author": { "url": "member/tomhe", "name": "tomhe", "avatar": "https://cdn.v2ex.com/gravatar/cc514dbe148cdb0b2fe1e7c9554b0893?s=73&d=retro" }, "url": "t/300584", "title": "\u95ee\u4e00\u4e2a tornado \u89e3\u51b3\u963b\u585e\u7684\u65b9\u6848\u95ee\u9898\uff1f", "id": "t/300584", "date_published": "2016-08-20T02:25:35+00:00", "content_html": "\u73b0\u5728\u7684\u9700\u6c42\u662f\uff1a\r\u6700\u8fd1\u5728\u7528 Python \u5f00\u53d1\u4e00\u4e2a\u81ea\u5df1\u7684\u7f51\u7ad9\uff0c\u8981\u7528\u5230\u4e03\u725b\u505a\u4e3a\u7f51\u7ad9\u7684 storage \uff0c\u4f46\u662f\u4e03\u725b\u5b98\u65b9 sdk \u4e0d\u652f\u6301\u5f02\u6b65\uff0c\u6240\u4ee5\u6253\u7b97\u81ea\u5df1\u5199\u4e00\u4e2a\u5f02\u6b65\u7684 sdk \u3002\u5199\u51fa\u6765\u4e4b\u540e\u81ea\u5df1\u7528\u7740\u8fd8\u53ef\u4ee5\uff0c\u6240\u4ee5\u60f3\u7ed9\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\uff0c\u4e0d\u559c\u52ff\u55b7\u3002
\npython version : >=3.4
\ngithub: https://github.com/free-free/tornaqiniu
\ndoc: https://github.com/free-free/tornaqiniu
\n" }, { "author": { "url": "member/aiqier", "name": "aiqier", "avatar": "https://cdn.v2ex.com/gravatar/7722f001ef46dc94410465ebfdf2ac3b?s=73&d=retro" }, "url": "t/289477", "date_modified": "2016-06-30T14:47:11+00:00", "content_html": "tornado \u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u65b9\u5f0f\u5e76\u884c\u5f02\u6b65\u8bf7\u6c42\u3002
\n@gen.coroutine\ndef get(self):\n http_client = AsyncHTTPClient()\n response1, response2 = yield [http_client.fetch(url1),\n http_client.fetch(url2)]\n\n\u8fd9\u4e2a\u65f6\u5019\uff0c 1,2 \u662f\u540c\u65f6\u53d1\u9001\u51fa\u53bb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u8ba9 n \u4e2a\u8bf7\u6c42\uff0c\u540c\u65f6\u53d1\u51fa\u53bb\uff0c\u7b49\u4ed6\u4eec\u90fd\u8fd4\u56de\u4e86\u518d\u7edf\u4e00\u8fd4\u56de\u3002
\n\u90a3\u4e48\u6211\u8981\u5982\u4f55\u4fdd\u8bc1\uff0c\u5176\u4e2d\u4e00\u4e2a\u8bf7\u6c42\u574f\u4e86\uff0c\u5176\u4f59\u7684\u7ed3\u679c\u4f9d\u65e7\u53ef\u7528\uff1f
\n", "date_published": "2016-06-30T14:46:47+00:00", "title": "tornado \u5e76\u884c\u5f02\u6b65\uff0c\u5982\u4f55\u4fdd\u8bc1\u5728\u53ea\u6709\u90e8\u5206\u8bf7\u6c42\u6210\u529f\u540e\uff0c\u7ed3\u679c\u4f9d\u65e7\u53ef\u7528\u3002", "id": "t/289477" }, { "author": { "url": "member/qiu0130", "name": "qiu0130", "avatar": "https://cdn.v2ex.com/avatar/1e44/2104/139692_large.png?m=1443080447" }, "url": "t/289074", "title": "nginx \u53cd\u5411\u4ee3\u7406 tornado,\u5982\u4f55 location \u9996\u9875\uff55 rl?", "id": "t/289074", "date_published": "2016-06-29T03:54:36+00:00", "content_html": "nginx\u53cd\u5411\u4ee3\u7406tornado\u5b9e\u4f8b\uff0c\u600e\u4e48\u91cd\u5b9a\u5411\u5230\u9996\u9875url
\u521a\u5f00\u59cb\u5b66 tornado \uff0c\u5b83\u7684\u5f02\u5e38\u5904\u7406\u673a\u5236\u6709\u70b9\u5f04\u4e0d\u660e\u767d\u3002
\n\u5199\u4e86\u4e00\u4e2a\u6d4b\u8bd5\u7528\u7684\u5c0f\u811a\u672c\uff0c\u671f\u671b\u9047\u5230 404 \u7684\u65f6\u5019\u80fd\u591f\u89e6\u53d1\u6211\u81ea\u5df1\u58f0\u660e\u7684 write_error \u51fd\u6570\uff0c\u7136\u800c write_error \u5e76\u6ca1\u6709\u751f\u6548\uff0c\u8f93\u51fa\u7684\u662f tornado \u9ed8\u8ba4\u7684 404 \u9875\u9762\u3002
\n\u4ee3\u7801\u5982\u4e0b\uff1a
\n#!/bin/env python3.5\n#coding:utf-8\nimport os\n\nimport tornado.httpserver\nimport tornado.ioloop\nimport tornado.options\nimport tornado.web\n\nfrom tornado.options import define, options\n\ndefine(\"port\", default=8000, help=\"\u7aef\u53e3\", type=int)\n\nclass BaseHandler(tornado.web.RequestHandler):\n def write_error(self, stat, **kw):\n self.write('Func write_error !')\n\n\nclass IndexHandler(BaseHandler):\n def get(self):\n self.write('hello')\n\nhandlers = [ \n (r'/index', IndexHandler),\n ] \n\nsettings = { \n 'template_path': os.path.join(os.path.dirname(__file__), \"templates\"),\n 'static_path': os.path.join(os.path.dirname(__file__), 'static'),\n }\n\nif __name__ == '__main__':\n tornado.options.parse_command_line()\n app = tornado.web.Application(handlers=handlers, **settings)\n http_server = tornado.httpserver.HTTPServer(app)\n http_server.listen(options.port)\n print(options.port)\n tornado.ioloop.IOLoop.instance().start()\n\n\u7136\u540e\u53bb google \u4e86\u4e00\u4e0b\uff0c\u628a BaseHandler \u6210\u4e86\u8fd9\u6837\uff0c\u4f46\u662f 404 \u7684\u65f6\u5019\u8fd8\u662f\u8fd4\u56de\u4e86\u9ed8\u8ba4\u7684 404 \u9875\u9762\uff1a
\nclass BaseHandler(tornado.web.RequestHandler):\n def _handle_request_exception(self, e):\n self.write_error(404)\n\n def send_error(self, stat, **kw):\n self.write_error(404)\n\n def write_error(self, stat, **kw):\n self.write('Func write_error !')\n\n", "date_published": "2016-06-05T09:07:42+00:00", "title": "\u95ee\u4e00\u4e2a\u5173\u4e8e tornado \u5f02\u5e38\u5904\u7406\u7684\u65b0\u624b\u95ee\u9898", "id": "t/283654" }, { "author": { "url": "member/triThirty", "name": "triThirty", "avatar": "https://cdn.v2ex.com/avatar/464b/8ffa/122253_large.png?m=1441520884" }, "url": "t/269198", "title": "tornado \u7684 coroutine \u80fd\u548c\u81ea\u5b9a\u4e49\u7684\u88c5\u9970\u5668\u4e00\u8d77\u4f7f\u7528\u5417\uff1f\uff1f", "id": "t/269198", "date_published": "2016-04-07T03:45:17+00:00", "content_html": "\u8bd5\u4e86\u4e0b\u4f7f\u7528 tornado \u7684 coroutine \u548c\u81ea\u5df2\u5b9a\u4e49\u7684\u4e00\u4e2a decorator \u4e00\u8d77\u4f7f\u7528\uff0c\u4f46\u53d1\u73b0\u4e0d\u4f1a\u5728 yield \u51fa\u6302\u8d77\uff0c\u800c\u662f\u5411\u4e0a\u8fd4\u56de\u3002\n\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u6709\u591a\u5c42\u5d4c\u5957\u7684\u8bdd\uff0c\u5728\u8fd0\u884c\u5230\u6700\u5e95\u5c42\u7684 yield \u5904\u4e4b\u540e\uff0c\u7a0b\u5e8f\u4e0d\u4f1a\u8fd0\u884c yield \u4e4b\u540e\u7684\u4ee3\u7801\uff0c\u800c\u662f\u5411\u4e0a\u8fd4\u56de\u4e00\u4e2a\u7a7a\u7684 future \uff0c\u800c\u4e14\u4e0a\u5c42\u4ee3\u7801\u4e5f\u4e0d\u4f1a\u6267\u884c yield \u4e4b\u540e\u7684\u4ee3\u7801\u800c\u662f\u7ee7\u7eed\u5411\u4e0a\u8fd4\u56de\u3002\n\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u5927\u795e\u80fd\u7ed9\u51fa\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5c06 coroutine \u548c\u81ea\u5b9a\u4e49\u7684\u88c5\u9970\u5668\u4e00\u8d77\u4f7f\u7528\u7684\u4f8b\u5b50\uff0c\u6216\u8005\u8bf4\u80fd\u6307\u51fa\u600e\u4e48\u4f7f\u7528\u3002\u8c22\u8c22
\n" }, { "author": { "url": "member/bluesky139", "name": "bluesky139", "avatar": "https://cdn.v2ex.com/avatar/119f/6887/72959_large.png?m=1432863459" }, "url": "t/250767", "title": "Tornado \u5e76\u53d1\u6570\u5f88\u4f4e\uff0c\u6b63\u5e38\u4e48\uff1f", "id": "t/250767", "date_published": "2016-01-14T09:47:48+00:00", "content_html": "\u5728 localhost \u4e0b\u6d4b\u8bd5\uff0c\u50cf demo \u4e00\u6837\uff0c get \u6216 post \u91cc\u9762\u6ca1\u6709\u4efb\u4f55\u591a\u4f59\u7684\u8017\u65f6\u4ee3\u7801\uff0c\u76f4\u63a5\u8fd4\u56de\u3002\r\u4e0b\u9762\u662f tornado.httpclient.AsyncHTTPClient\u7c7b\u7684 fetch()\u65b9\u6cd5\u7684\u6e90\u4ee3\u7801\u3002\u6211\u6ca1\u6709\u5728\u91cc\u9762\u627e\u5230\u4efb\u4f55"fetch"\u7684\u52a8\u4f5c\uff0c\u5b83\u662f\u600e\u4e48\u5b9e\u73b0 \u201c Executes a request, asynchronously returning an HTTPResponse\u201d\u7684\uff1f
\u5b8c\u6574\u4ee3\u7801\u5728\uff1a https://github.com/tornadoweb/tornado/blob/master/tornado/httpclient.py
\ndef fetch(self, request, callback=None, raise_error=True, **kwargs):\n """Executes a request, asynchronously returning an `HTTPResponse`.\n The request may be either a string URL or an `HTTPRequest` object.\n If it is a string, we construct an `HTTPRequest` using any additional\n kwargs: ``HTTPRequest(request, **kwargs)``\n This method returns a `.Future` whose result is an\n `HTTPResponse`. By default, the ``Future`` will raise an\n `HTTPError` if the request returned a non-200 response code\n (other errors may also be raised if the server could not be\n contacted). Instead, if ``raise_error`` is set to False, the\n response will always be returned regardless of the response\n code.\n If a ``callback`` is given, it will be invoked with the `HTTPResponse`.\n In the callback interface, `HTTPError` is not automatically raised.\n Instead, you must check the response's ``error`` attribute or\n call its `~HTTPResponse.rethrow` method.\n """\n if self._closed:\n raise RuntimeError("fetch() called on closed AsyncHTTPClient")\n if not isinstance(request, HTTPRequest):\n request = HTTPRequest(url=request, **kwargs)\n else:\n if kwargs:\n raise ValueError("kwargs can't be used if request is an HTTPRequest object")\n # We may modify this (to add Host, Accept-Encoding, etc),\n # so make sure we don't modify the caller's object. This is also\n # where normal dicts get converted to HTTPHeaders objects.\n request.headers = httputil.HTTPHeaders(request.headers)\n request = _RequestProxy(request, self.defaults)\n future = TracebackFuture()\n if callback is not None:\n callback = stack_context.wrap(callback)\n\n def handle_future(future):\n exc = future.exception()\n if isinstance(exc, HTTPError) and exc.response is not None:\n response = exc.response\n elif exc is not None:\n response = HTTPResponse(\n request, 599, error=exc,\n request_time=time.time() - request.start_time)\n else:\n response = future.result()\n self.io_loop.add_callback(callback, response)\n future.add_done_callback(handle_future)\n\n def handle_response(response):\n if raise_error and response.error:\n future.set_exception(response.error)\n else:\n future.set_result(response)\n self.fetch_impl(request, handle_response)\n return future\n\ndef fetch_impl(self, request, callback):\n raise NotImplementedError()\n\u76ee\u524d\u9002\u914d\u4e86 pymysql, pymemcache \u548c storm \u7684\u5f02\u6b65\u5316\u652f\u6301.
\n\n\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u53ef\u8bbf\u95ee: https://github.com/alex8224/gtornado
\n" }, { "author": { "url": "member/mywaiting", "name": "mywaiting", "avatar": "https://cdn.v2ex.com/avatar/4f87/658e/1340_large.png?m=1733248338" }, "url": "t/239245", "title": "Tornado \u5982\u4f55\u7ec4\u7ec7\u4e2d\u5927\u578b\u9879\u76ee\uff0c\u4f60\u4eec\u90fd\u662f\u600e\u4e48\u6837\u505a\u7684\uff1f", "id": "t/239245", "date_published": "2015-11-26T14:24:16+00:00", "content_html": "\u7528\u4e86 tornado \u4e5f\u5199\u7f51\u7ad9\uff0c\u65e0\u5b83\uff0c\u5f53\u521d\u5c31\u662f\u56e0\u4e3a\u559c\u6b22\uff0c\u56e0\u4e3a tornado \u7684\u4ee3\u7801\u5199\u5f97\u771f\u5fc3\u6f02\u4eae\u3002\rContext \uff1a
\n- tornado \u7684 helloWorld \u6559\u7a0b\u4ee3\u7801\u8dd1\u4e0d\u901a\uff0c localhost:8000 \u4f1a\u62a5\u9519\u2018\u672a\u6536\u5230\u6570\u636e\u2019
\n- \u672c\u673a\u5e76\u672a\u88c5 Nginx \uff0c\u4f46\u662f 0.0.0.0 \u6253\u5f00\u540e\u4f1a\u663e\u793a Welcome to nginx!\u90a3\u4e2a\u6b22\u8fce\u9875
\n- terminal \u4e2d\uff0c nginx command not found
\nQuestion \uff1a
\n- \u5982\u4f55\u5b9a\u4f4d\u81ea\u5df1\u7684 nginx \u8f6c\u5230\u54ea\u91cc\u4e86\uff1f
\n- tornado \u7684 helloWorld \u54ea\u91cc\u4e0d\u5bf9\uff1f
def get(self):\n time.sleep(100)\n self.write('hello test')\n\u5982\u679c\u7a0b\u5e8f\u6267\u884c\u7684\u65f6\u5019\u4e2d\u95f4\u5904\u7406\u4e00\u4e2a\u9700\u8981\u5f88\u591a\u65f6\u95f4\uff0c\u8fd9\u4e2a\u65f6\u5019\u6709\u4e00\u4e2a\u65b0\u7684\u8bf7\u6c42
\n\u90a3\u4e48\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\u9700\u8981\u7b49\u5f85\u7b2c\u4e00\u4e2a\u8bf7\u6c42\u6267\u884c\u5b8c\u624d\u5f00\u59cb\u6267\u884c\u7b2c\u4e8c\u4e2a\u64cd\u4f5c
\n\u63a5\u7740\u7528 nginx \u505a\u4e86\u4e00\u4e2a\u8d1f\u8f7d\u5747\u8861\uff0c\u5f00\u4e86 3 \u4e2a tornado
upstream to.com{\n server 127.0.0.1:8887;\n server 127.0.0.1:8888;\n server 127.0.0.1:8889;\n }\n\u53ef\u662f\u4e2d\u95f4\u8fd8\u662f\u6709\u673a\u7387\u5207\u5230\u540c\u4e00\u4e2a\u7aef\u53e3\u4e0a\u9762\uff0c\u7136\u540e\u53c8\u8981\u7b49\u5f85\u5904\u7406\uff0c\u6709\u4ec0\u4e48\u5176\u4ed6\u5904\u7406\u65b9\u9762\u5417\uff1f
\n", "date_published": "2015-10-15T08:11:43+00:00", "title": "\u5173\u4e8e tornado \u963b\u585e\u7684\u95ee\u9898", "id": "t/228298" }, { "author": { "url": "member/sujin190", "name": "sujin190", "avatar": "https://cdn.v2ex.com/avatar/e66f/964a/36127_large.png?m=1732868751" }, "url": "t/226295", "title": "tornado \u7684 mysql \u5f02\u6b65\u9a71\u52a8\u6027\u80fd\u6d4b\u8bd5", "id": "t/226295", "date_published": "2015-10-08T05:50:58+00:00", "content_html": "" }, { "author": { "url": "member/sujin190", "name": "sujin190", "avatar": "https://cdn.v2ex.com/avatar/e66f/964a/36127_large.png?m=1732868751" }, "url": "t/219815", "title": "pypy \u4e4b tornado", "id": "t/219815", "date_published": "2015-09-10T15:24:11+00:00", "content_html": "\u5728 pypy \u4e0b\u6d4b\u8bd5\u4e86\u4e0b tornado \uff0c\u6ca1\u6709\u6570\u636e\u5e93\u7684\u60c5\u51b5\u4e0b ab -c1000 \u53ef\u4ee5\u8dd1\u5230 20000 \u591a qps \uff0c\u5e26 mysql \u67e5\u8be2\u5355\u884c\u4e24\u4e2a\u5b57\u6bb5\u7684\u6570\u636e\u4e5f\u80fd\u8dd1\u5230 1000 \u5de6\u53f3 qps \uff0c pypy \u5bf9 torndao \u7684\u63d0\u5347\u8fd8\u662f\u633a\u591a\u7684\u554a\u3002\r\u8bf7\u95ee\u5404\u4f4d, \u670d\u52a1\u5668\u7aef\u7528\u7684tornado, \u5047\u5982\u51e0\u4e2adomain\u90fd\u6307\u5411\u4e86\u540c\u4e00\u4e2a\u5730\u5740, \u5e94\u8be5\u600e\u4e48\u5f97\u5230\u88ab\u8bbf\u95ee\u7684\u57df\u540d\u5462?
\n", "date_published": "2015-08-08T11:19:47+00:00", "title": "tornado \u591a\u4e2a url", "id": "t/211788" }, { "author": { "url": "member/roychan", "name": "roychan", "avatar": "https://cdn.v2ex.com/gravatar/81a46497b9e8abce7479fe40d7bf8f7b?s=73&d=retro" }, "url": "t/208772", "date_modified": "2015-07-27T15:45:41+00:00", "content_html": "\u521a\u521a\u5f00\u59cb\u7528 Tornado\u3002
\n\n\u5728\u7528\u6237\u8ba4\u8bc1\u65f6\uff0c\u6211\u8986\u5199\u4e86 BaseHandler\uff0c\u4ee5\u4fbf\u4f7f\u7528\u5185\u7f6e\u7684 current_user() \u65b9\u6cd5\u4e0e is_authenticated \u4fee\u9970\u5668\u3002
\nclass BaseHandler(tornado.web.RequestHandler):\n def get_current_user(self):\n return self.get_secure_cookie('user')\n\u5728\u67d0\u6b65\u4e2d\uff0c\u6211\u52a0\u4e86\u5224\u65ad if self.current_user then xxx\uff0c\u6b64\u65f6\u5373\u4fbf\u767b\u5f55\u4e86\u4e5f\u65e0\u6cd5\u6267\u884c xxx\uff0c\u5982\u679c\u6211\u628a\u5224\u65ad\u5199\u6210 if self.get_current_user then xxx\uff0c\u4fbf\u80fd\u6210\u529f\u786e\u8ba4\u767b\u5f55\uff0cxxx \u5c31\u6267\u884c\u4e86\u3002
\n\n\u8bf7\u95ee\u8fd9\u53ef\u80fd\u662f\u4ec0\u4e48\u95ee\u9898\uff1f
\n", "date_published": "2015-07-27T15:43:49+00:00", "title": "RequestHandler \u7c7b\u7684 get_current_user() \u65b9\u6cd5\u8986\u5199\u65e0\u6548", "id": "t/208772" }, { "author": { "url": "member/agentwx", "name": "agentwx", "avatar": "https://cdn.v2ex.com/avatar/228e/bc0d/78510_large.png?m=1468483025" }, "url": "t/206354", "title": "tornado \u52a8\u6001\u6dfb\u52a0 url \u7684\u95ee\u9898", "id": "t/206354", "date_published": "2015-07-17T05:04:14+00:00", "content_html": "\u6700\u8fd1\u5728\u770btornado \uff0c \u770b\u5230\u5b83\u7684url\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u4e00\u822c\u662furl(r"/path",sthhandler),\u7a81\u7136\u5fc3\u91cc\u60f3\u5230\u80fd\u4e0d\u80fd\u76f4\u63a5\u52a8\u6001\u521b\u5efa\u8fd9\u4e2aurl\uff0csthhandler\u4e00\u822c\u90fd\u662f\u4e00\u4e2a\u7c7b\uff0c\u5982\u679c\u52a8\u6001\u521b\u5efa\u4e86\u4e00\u4e2aurl, \u76f8\u5e94\u7684handler\u5982\u4f55\u52a8\u6001\u751f\u6210\u5462\uff1f \u76f4\u63a5\u4ee5py\u6587\u4ef6\u7684\u5f62\u5f0f\u751f\u6210\uff1f
\n" }, { "author": { "url": "member/evolsnow", "name": "evolsnow", "avatar": "https://cdn.v2ex.com/avatar/ae52/b061/29293_large.png?m=1472388707" }, "url": "t/199922", "date_modified": "2015-06-19T13:40:40+00:00", "content_html": "\u5728/test\u7684handler\u6dfb\u52a0\u4e86@tornado.web.authenticated, \u672a\u767b\u5f55\u8bbf\u95ee\u65f6\u8df3\u8f6c\u5230\u8bbe\u7f6e\u7684/login.
\n\u6b64\u65f6\u7f51\u5740\u4e3a"/login?next=%2Ftest", \u867d\u7136\u8bbe\u7f6e\u4e86:self.redirect(self.get_argument("next", "/"))
\n\u4f46\u662f\u767b\u5f55\u540e\u4e0d\u8fd4\u56de\u81f3"/test"\u800c\u662f\u5230\u4e86\u9ed8\u8ba4\u7684"/"\u9875\u9762
\u7f51\u4e0a\u641c\u7d22\u65e0\u679c,\u95ee\u9898\u548c\u8fd9\u5927\u54e5\u4e00\u6837:
\nhttp://stackoverflow.com/questions/20290020/tornado-next-query-string-url-parameter
\n\u4e0d\u8fc7\u8be5\u7b54\u6848\u5e76\u672a\u89e3\u51b3\u95ee\u9898, \u6240\u4ee5\u7ee7\u7eed\u6765v\u7ad9\u6c42\u89e3
\u5b98\u65b9\u4f8b\u5b50:
\n\nfrom tornado.concurrent import Future
\n\ndef async_fetch_future(url):
\n http_client = AsyncHTTPClient()
\n my_future = Future()
\n fetch_future = http_client.fetch(url)
\n fetch_future.add_done_callback(
\n lambda f: my_future.set_result(f.result()))
\n return my_future
\n\u4ec0\u4e48\u534f\u7a0b,\u5f02\u6b65\u8ff7\u8ff7\u7cca\u7cca\u7684!
\u5b8c\u5168\u4e0d\u61c2 my_future = Future() \u4e3a\u4ec0\u4e48\u8981\u751f\u6210\u4e2a Future \u5bf9\u8c61,\u6700\u540e\u53c8\u8fd4\u56de\u5b83\uff01\uff01\u5df2\u7ecf\u75db\u82e6\u4e86\u51e0\u5929\u4e86\uff01\uff01\u5927\u795e\u6765\u89e3\u6551\u4e0b\u6211\u5427
\n", "date_published": "2015-04-09T07:33:06+00:00", "title": "\u65b0\u624b\u5b8c\u5168\u4e0d\u61c2 tornado.concurrent.Future", "id": "t/182595" }, { "author": { "url": "member/waynee", "name": "waynee", "avatar": "https://cdn.v2ex.com/avatar/5dd3/b684/38050_large.png?m=1426133920" }, "url": "t/182359", "date_modified": "2015-04-08T19:41:36+00:00", "content_html": "RT\uff0c\u505a\u4e00\u4e2a\u8c03\u67e5\u3002\u76ee\u524d\u7684\u60c5\u51b5\u662f\uff0c\u4e00\u4e2a Tornado \u8fdb\u7a0b\uff0c \u7136\u540e\u6309\u6211\u7684\u7406\u89e3\uff0c\u8bf7\u6c42\u6765\u4e86\u4ee5\u540e\uff0c\u4f1a\u81ea\u5df1\u5f00\u7ebf\u7a0b\u5904\u7406\u7684\u3002 \u90a3\u4e48\u95ee\u9898\u6765\u4e86\uff1a
\n\n1\u3001\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u8bfb\u53d6SQLite\uff0c\u4f1a\u6709\u9501\u5b9a\u4e48\uff1f \u7f51\u4e0a\u8bf4\u591a\u4e2a\u8fdb\u7a0b\u53ef\u4ee5\u540c\u65f6\u8bfb\u5199\uff0c\u4f46\u8bf4\u5199\u7684\u65f6\u5019\u6709\u9501\u5b9a\uff0c\u90a3\u8bfb\u7684\u65f6\u5019\uff0c\u662f\u4e0d\u662f\u90fd\u80fd\u7acb\u9a6c\u8fd4\u56de\uff1f\u5982\u679c\u53ef\u4ee5\u7acb\u9a6c\u8fd4\u56de\uff0c \u90a3\u5e94\u8be5\u53ef\u4ee5\u5f00\u591a\u4e2a Tornado \u4e86\u5427\uff1f
\n\n2\u3001\u591a\u4e2a\u7ebf\u7a0b\u4e4b\u95f4\uff0c\u4e0d\u80fd\u5171\u4eab\u53e5\u67c4\u4e48\uff1f\u7f51\u4e0a\u8bf4\uff0c\u591a\u7ebf\u7a0b\u4e4b\u95f4\u5171\u4eab\u53e5\u67c4\u53ef\u80fd\u5b58\u5728\u95ee\u9898\uff0c\u90a3\u591a\u7ebf\u7a0b\u67e5\u8be2\u7684\u8bdd\uff0c\u6bcf\u6b21\u8981connect\uff0c\u7136\u540e\u5728close\u4e48\uff1f \u600e\u4e48\u6837\u80fd\u5728 Tornado \u91cc\u4fdd\u6301SQLite\u7684\u957f\u8fde\u63a5\u5462\uff1f
\n\n\u76ee\u524d\u7684\u9700\u6c42\u662f\uff1a SQLite \u53ea\u8bfb\uff0c\u6ca1\u6709\u5199\u7684\u9700\u6c42\u3002
\n" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1777863673" }, "url": "t/172185", "title": "Tornado 4.1", "id": "t/172185", "date_published": "2015-02-22T10:13:58+00:00", "content_html": "http://www.tornadoweb.org/en/stable/releases/v4.1.0.html" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1777863673" }, "url": "t/171602", "title": "\u5173\u4e8e\u4f18\u96c5\u5730\u90e8\u7f72 Tornado \u65b0\u4ee3\u7801\u7684\u4e00\u79cd\u65b9\u5f0f", "id": "t/171602", "date_published": "2015-02-17T23:28:33+00:00", "content_html": "http://stackoverflow.com/questions/8086885/is-there-a-way-to-deploy-new-code-with-tornado-python-without-restarting-the-ser" }, { "author": { "url": "member/jecvay", "name": "jecvay", "avatar": "https://cdn.v2ex.com/avatar/5d88/04b8/75586_large.png?m=1668072609" }, "url": "t/170521", "title": "Tornado Template \u5982\u4f55\u83b7\u5f97 Javascript \u4e2d\u7684 var \u53d8\u91cf?", "id": "t/170521", "date_published": "2015-02-12T09:11:58+00:00", "content_html": "\u6211\u60f3\u901a\u8fc7jQuery \u53d1\u8d77\u4e00\u4e2a\u5bf9api\u7684GET\u8bf7\u6c42, \u83b7\u5f97\u4e00\u4e2ajson\u683c\u5f0f\u7684list, \u7136\u540e\u7528 {% for %}\u63a7\u5236\u8bed\u53e5\u6765\u628ajson\u91cc\u9762\u7684\u6bcf\u4e00\u4e2aTitle\u7ed9\u663e\u793a\u51fa\u6765.
\n\n\u6c42\u6559\u5982\u4f55\u5728 {% %} \u91cc\u9762\u8c03\u7528 jQuery\u83b7\u5f97\u7684data
\n" }, { "author": { "url": "member/pagict", "name": "pagict", "avatar": "https://cdn.v2ex.com/avatar/96a0/cc2f/9380_large.png?m=1572610161" }, "url": "t/164660", "date_modified": "2015-01-22T16:39:42+00:00", "content_html": "\u6700\u8fd1\u5728\u8ddf\u7740 Introduction to Tornado \u5b66Tornado\uff0c\u505a\u5230Chapter5 \u7684 Live Inventory Reporting \u793a\u4f8b\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6ca1\u6709\u60f3\u8981\u7684\u6548\u679c\u3002\u6211\u6ca1\u6709\u5f00\u53d1\u7f51\u7ad9\u7684\u7ecf\u9a8c, \u53ea\u662f\u770b\u8fc7\u4e86Python\u548cTornado\u90a3\u672c100\u591a\u9875\u7684\u5165\u95e8\u4e66.
\n\u73b0\u5728\u6709\u4e2a\u9879\u76ee\u662f\u505a\u4e2a\u7ba1\u7406\u7cfb\u7edf\u7f51\u7ad9, \u6253\u7b97\u7528 Mongodb \u6570\u636e\u5e93.
\n\u800c\u4e14\u6211\u5bf9\u5f02\u6b65\u4ec0\u4e48\u7684\u6ca1\u6709\u4efb\u4f55\u7ecf\u9a8c,
\u8bf7\u95ee\u6709\u4ec0\u4e48\u8981\u6ce8\u610f\u7684?
\n", "date_published": "2015-01-20T05:35:00+00:00", "title": "\u7528 Tornado + Mongodb \u5f00\u53d1\u8981\u6ce8\u610f\u4ec0\u4e48?", "id": "t/163815" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1777863673" }, "url": "t/163238", "title": "\u7528 Tornado \u505a\u7684\u7f51\u7ad9\uff0c\u5927\u5bb6\u5728\u5199\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u4e00\u822c\u90fd\u662f\u600e\u4e48\u505a\u7684\u5462\uff1f", "id": "t/163238", "date_published": "2015-01-18T09:08:41+00:00", "content_html": "" }, { "author": { "url": "member/mqingyn616", "name": "mqingyn616", "avatar": "https://cdn.v2ex.com/avatar/7ec9/a2d2/91953_large.png?m=1421303756" }, "url": "t/162401", "title": "\u5206\u4eab\u672c\u4eba\u57fa\u4e8e tornado \u5f00\u53d1\u7684\u5e94\u7528\u5c42\u6846\u67b6", "id": "t/162401", "date_published": "2015-01-15T06:31:38+00:00", "content_html": "https://github.com/mqingyn/torngas
\n\nTorngas \u662f\u57fa\u4e8eTornado\u7684\u5e94\u7528\u5f00\u53d1\u6846\u67b6\uff0ctornado\u662f\u4e00\u4e2a\u5f02\u6b65\u975e\u963b\u585e\u7684web\u6846\u67b6\uff0c\u4f46\u662f\u7531\u4e8e\u5176\u5c0f\u5de7\u7075\u6d3b\uff0c\u5e76\u6ca1\u6709\u4e00\u4e2a\u7edf\u4e00\uff0c\u901a\u7528\u7684 \u5e94\u7528\u5c42\u6846\u67b6\u89e3\u51b3\u65b9\u6848\u3002Torngas \u5927\u91cf\u53c2\u8003\u548c\u501f\u9274\u4e86Django\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5f62\u6210\u4e00\u5957\u57fa\u4e8etornado\u7684Django like\u5e94\u7528\u5c42\u5f00\u53d1\u6846\u67b6\u3002
\n\u8fd9\u4e2a\u6846\u67b6\u5df2\u7ecf\u5e94\u7528\u5728\u5343\u4e07\u7ea7PV\u7684\u9879\u76ee\u91cc\uff0c\u73b0\u5728\u5f00\u6e90\u51fa\u6765\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u7528\u3002^ _^
\u914d\u7f6e\u4e86 Nginx \u4f1a\u5c06\u8bf7\u6c42\u5206\u7ed9 8000:8003 \u56db\u4e2a\u7aef\u53e3, \u6211\u60f3Tornado\u5efa\u4e00\u4e2a\u9875\u9762, \u8bbf\u95ee\u8fd9\u4e2a\u9875\u9762\u7684\u65f6\u5019\u6d4f\u89c8\u5668\u4e0a\u80fd\u663e\u793a\u51fa\u8fd9\u4e2a\u9875\u9762\u7684\u8bf7\u6c42\u7531\u54ea\u4e00\u4e2a\u7aef\u53e3\u83b7\u53d6\u4e86, \u5982\u4f55\u80fd\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd?
\n\nRequestHandler \u8c8c\u4f3c\u6ca1\u6709\u4f20\u8fdb\u6765\u7aef\u53e3\u53f7?
\n" }, { "author": { "url": "member/blueandhack", "name": "blueandhack", "avatar": "https://cdn.v2ex.com/avatar/c03d/ada7/34443_large.png?m=1707800861" }, "url": "t/156122", "title": "Tornado \u6846\u67b6\u5982\u4f55\u5199 MVC \u6a21\u5f0f\uff1f", "id": "t/156122", "date_published": "2014-12-23T13:06:49+00:00", "content_html": "\u4e4b\u524d\u5199\u8fc7Nodejs\uff0c\u4e0d\u77e5\u9053Tornado\u5982\u4f55\u6765\u5199\uff0c\u6709\u53ef\u4ee5\u53c2\u8003\u7684\u4f8b\u5b50\u5417\uff1f