我正在使用Coroutine功能构建Tornado Web应用程序。为了测试应用程序的性能,我使用了Siege。但是,使用Siege调用URL时发生了503错误。顺便说一下,我的应用程序在Raspberry Pi上运行。
我的应用的片段:
import os
import tornado.web
import tornado.gen
import tornado.ioloop
import tornado.options
import tornado.httpclient
tornado.options.define("port", default=8888, help="message...", type=int)
url='http://..../'
class Async(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
client = tornado.httpclient.AsyncHTTPClient()
response = yield client.fetch(url)
self.write('%r' % response.body)
def main():
# Command line
tornado.options.parse_command_line()
app = tornado.web.Application(
[
(r'/async', Async)
],
debug=True,
autoreload=True
)
app.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()
命令:
siege 192.168.1.x:8888/async -c 5 -r 5
错误信息:
[E 150822 18:47:15 web:1908] 500 GET /async (192.168.1.3) 2045.97ms
[I 150822 18:47:15 web:1908] 200 GET /async (192.168.1.3) 3317.43ms
[E 150822 18:47:16 web:1496] Uncaught exception GET /async (192.168.1.3)
HTTPServerRequest(protocol='http', host='192.168.1.x:8888', method='GET', uri='/async', version='HTTP/1.1', remote_ip='192.168.1.3', headers={'Host': '192.168.1.9:8888', 'User-Agent': 'Mozilla/5.0 (apple-x86_64-darwin14.4.0) Siege/3.1.0', 'Connection': 'close', 'Accept': '*/*', 'Accept-Encoding': 'gzip'})
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/tornado/web.py", line 1415, in _execute
result = yield result
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/usr/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 876, in run
yielded = self.gen.throw(*exc_info)
File "server.py", line 19, in get
response = yield client.fetch(url)
File "/usr/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/usr/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
HTTPError: HTTP 503: Service Temporarily Unavailable
[E 150822 18:47:16 web:1908] 500 GET /async (192.168.1.x) 3645.07ms
那么,我是否省略了一些设置?
如果你能指出我的应用程序出了什么问题,我将非常感激。 非常感谢你。
答案 0 :(得分:0)
我将网址更改为http://www.google.com,并且没有发生503错误。我还在Mac上测试了我的应用程序,它运行良好。因此,我认为这些错误是由于我获取数据的原因所致。
无论如何,非常感谢你,SDilmac。