Tornado
来源:互联网 发布:c语言软件测试 编辑:程序博客网 时间:2024/05/24 05:03
Tornado 是一个基于Python的Web服务框架和 异步网络库, 最早开发与 FriendFeed 公司. 通过利用非阻塞网络 I/O, Tornado 可以承载成千上万的活动连接, 完美的实现了 长连接, WebSockets, 和其他对于每一位用户来说需要长连接的程序.
快速链接
- 下载版本4.4: tornado-4.4.dev1.tar.gz (发布说明)
- Source (github)
- 邮件列表: discussion 和 announcements
- Stack Overflow
- Wiki
Hello, world
这是一个基于Tornado的简易 “Hello, world” web应用程序:
import tornado.ioloopimport tornado.webclass MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world")def make_app(): return tornado.web.Application([ (r"/", MainHandler), ])if __name__ == "__main__": app = make_app() app.listen(8888) tornado.ioloop.IOLoop.current().start()
这个例子没有用到任何Tornado的异步特性; 如果有需要请查看这个例子 简易聊天室.
安装
自动安装:
pip install tornado
Tornado 可以在 PyPI 中被找到.而且可以通过 pip
或者 ``easy_install``来安装.注意这样安装Tornado 可能不会包含源代码中的示例程序, 所以你或许会需要一份软件的源代码.
手动安装: 下载 tornado-4.4.dev1.tar.gz.
tar xvzf tornado-release.tar.gzcd tornado-releasepython setup.py buildsudo python setup.py install
Tornado源代码 被托管在的 GitHub.
环境要求: Tornado 4.3 可以运行在 Python 2.7, 和 3.3+ 对于 Python 2, 版本 2.7.9 以上是被 强烈 推荐的由于这些版本提供了SSL. 除了在 pip
或者 setup.py install
中安装的依赖需求包之外, 以下包有可能会被用到:
- concurrent.futures is the recommended thread pool for use with Tornado and enables the use of
ThreadedResolver
. It is needed only on Python 2; Python 3 includes this package in the standard library. - pycurl is used by the optional
tornado.curl_httpclient
. Libcurl version 7.19.3.1 or higher is required; version 7.21.1 or higher is recommended. - Twisted may be used with the classes in
tornado.platform.twisted
. - pycares is an alternative non-blocking DNS resolver that can be used when threads are not appropriate.
- Monotime adds support for a monotonic clock, which improves reliability in environments where clock adjustments are frequent. No longer needed in Python 3.3.
- monotonic adds support for a monotonic clock. Alternative to Monotime. No longer needed in Python 3.3.
平台: Tornado 应该运行在类 Unix 平台, 对于Linux (通过 epoll
) 和 BSD (通过 kqueue
) 可以获得更好的性能和可扩展性, 但我们仅推荐它们来不熟产品 (虽然 Mac OS X 也是基于 BSD 的,并且也支持 kqueue, 但是它的网络性能十分的差所以 我们只推荐用它来进行开发). Tornado 也可以运行在 Windows 上, 虽然这并不是官方所推荐的, 我们仅仅推荐用它来做开发.
文档
这篇文档同时还有 PDF 和 Epub 格式.
- 用户手册
- 介绍
- 异步和非阻塞 I/O
- 协程
Queue
示例 - 一个并发网络爬虫- Tornado web 应用程序结构
- 模版和 UI
- 认证与安全
- 运行和部署
- Web 框架
tornado.web
—RequestHandler
andApplication
classestornado.template
— Flexible output generationtornado.escape
— Escaping and string manipulationtornado.locale
— Internationalization supporttornado.websocket
— Bidirectional communication to the browser
- HTTP 服务器和客户端
tornado.httpserver
— Non-blocking HTTP servertornado.httpclient
— Asynchronous HTTP clienttornado.httputil
— Manipulate HTTP headers and URLstornado.http1connection
– HTTP/1.x client/server implementation
- 异步网路
tornado.ioloop
— Main event looptornado.iostream
— Convenient wrappers for non-blocking socketstornado.netutil
— Miscellaneous network utilitiestornado.tcpclient
—IOStream
connection factorytornado.tcpserver
— BasicIOStream
-based TCP server
- 协程和并发
tornado.gen
— Simplify asynchronous codetornado.concurrent
— Work with threads and futurestornado.locks
– Synchronization primitivestornado.queues
– Queues for coroutinestornado.process
— Utilities for multiple processes
- 整合其它服务
tornado.auth
— Third-party login with OpenID and OAuthtornado.wsgi
— Interoperability with other Python frameworks and serverstornado.platform.asyncio
— Bridge betweenasyncio
and Tornadotornado.platform.caresresolver
— Asynchronous DNS Resolver using C-Arestornado.platform.twisted
— Bridges between Twisted and Tornado
- 实用工具
tornado.autoreload
— Automatically detect code changes in developmenttornado.log
— Logging supporttornado.options
— Command-line parsingtornado.stack_context
— Exception handling across asynchronous callbackstornado.testing
— Unit testing support for asynchronous codetornado.util
— General-purpose utilities
- 问题与解答
- 发布说明
- Tornado 4.3 新特性
- Tornado 4.2.1 新特性
- Tornado 4.2 新特性
- Tornado 4.1 新特性
- Tornado 4.0.2 新特性
- Tornado 4.0.1 新特性
- Tornado 4.0 新特性
- Tornado 3.2.2 新特性
- Tornado 3.2.1 新特性
- Tornado 3.2 新特性
- Tornado 3.1.1 新特性
- Tornado 3.1 新特性
- Tornado 3.0.2 新特性
- Tornado 3.0.1 新特性
- Tornado 3.0 新特性
- Tornado 2.4.1 新特性
- Tornado 2.4 新特性
- Tornado 2.3 新特性
- Tornado 2.2.1 新特性
- Tornado 2.2 新特性
- Tornado 2.1.1 新特性
- Tornado 2.1 新特性
- Tornado 2.0 新特性
- Tornado 1.2.1 新特性
- Tornado 1.2 新特性
- Tornado 1.1.1 新特性
- Tornado 1.1 新特性
- Tornado 1.0.1 新特性
- Tornado 1.0 新特性
- Tornado 4.3 新特性
Indices and tables
- 索引
- 模块索引
- 搜索页面
讨论和支持
你可以在 Tornado 开发人员邮件列表 中对 Tornado 进行讨论, 并且可以在 GitHub 问题跟踪 中汇报问题. 其他的资源可以在 Tornado wiki 中找到. 新版本通知在 通知邮件列表.
Tornado 遵循 Apache License, Version 2.0.
本网页和所有的文档都遵循 Creative Commons 3.0.
中文文档由 我是黑夜 翻译完成. 译文版权归原作者和译者所有.
- tornado
- Tornado
- Tornado
- tornado
- Tornado
- tornado
- tornado
- Tornado
- tornado
- Tornado
- Tornado
- Tornado
- Tornado
- tornado
- Tornado简介
- asynchronous@tornado
- Tornado 安装
- Tornado 安装
- Android客制化------7.0设置壁纸存在的一些问题
- Liferay7.0的安装初始化与使用
- myeclipse10配置maven
- android aidl oneway用法
- 移动端上下滑动swiper,第二个页面内容大于屏幕尺寸,现在的问题是,超出部分无法通过滚动条下滑查看。
- Tornado
- UVa201
- dcloud------mui 点击底部选项卡,获取文本内容
- 五分钟让你全面理解ADO.NET连接池
- CBoard BI 数据可视化 支持国产开源
- 机器学习之决策树实现隐形眼镜预测
- 知识总结之 插件化学习 Hook系统方法分析
- 足迹001
- Python装饰器