python 非阻塞异步处理web 框架 tornado

tornado 安装

1.git下载tornado

git clone https://github.com/tornadoweb/tornado.gie

2. 进入下载tornado 文件夹

cd tornado

3. bulid tornado

python setup.py build

4.install tornado

python setup.py install

-------------------------------------------------------------------------------------------------------------

python setup.py install 需要pipy连接外网资源,没有外网的虚机是不能安装成功的

-------------------------------------------------------------------------------------------------------------

用tornado 写一个循环访问urldemo

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://10.58.100.90/jsondatedemo.txt'
i = 1
#print(param)
#req = tornado.httpclient.HTTPRequest(url, 'POST', body=str(param))
req = tornado.httpclient.HTTPRequest(url, 'GET')
http_client = AsyncHTTPClient()
while i<10:
  i += 1
  http_client.fetch(req, handle_request)
tornado.ioloop.IOLoop.instance().start()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值