python 龙卷风使未来
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 龙卷风使未来相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado import gen
from tornado.httpclient import AsyncHTTPClient
import time
import urllib2
from tornado.options import define, options
define("port", default=8888, help="run on the given port", type=int)
@tornado.concurrent.return_future
def calculate(callback):
start_time = time.time()
res = urllib2.urlopen("https://www.baidu.com/")
print time.time()-start_time
callback(res)
class MainHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
start_time = time.time()
res = yield [calculate(), calculate()]
print time.time()-start_time
def main():
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()
以上是关于python 龙卷风使未来的主要内容,如果未能解决你的问题,请参考以下文章
如何在数据库中使龙卷风请求成为原子
龙卷风发生器在列表中的任何未来恢复
python 将websockets与龙卷风结合起来,龙卷风用于控制
python龙卷风中的SSL(https)
python 龙卷风
python 龙卷风的websocket样本