tornado 压力测试

作者: 望月成三人 | 来源:发表于2016-06-12 09:44 被阅读654次
    • 异步压力测试请求客户端,下面代码是post请求
    import tornado.ioloop
    from tornado.httpclient import AsyncHTTPClient
    def handle_request(response):
        if response.error:
            print ("Error:", response.error)
        else:
            print(response.body)
    param = {"msg":"111"}
    param["img_msg"] = open("t.jpg",'r',encoding='utf-8')
    url = 'http://gc.ditu.aliyun.com/geocoding?a=苏州市'
    i = 1
    print(param)
    req = tornado.httpclient.HTTPRequest(url, 'POST', body=str(param))
    http_client = AsyncHTTPClient()
    while i<10000:
        i += 1
        http_client.fetch(req, handle_request)
    tornado.ioloop.IOLoop.instance().start()
    

    相关文章

      网友评论

        本文标题:tornado 压力测试

        本文链接:https://www.haomeiwen.com/subject/mhyedttx.html