搜索

epub文档 Tornado 4.5 Documentation

322.34 KB 333 页 0 下载 198 浏览 0 评论 0 收藏
语言 格式 评分
英语
.epub
3
摘要
The document provides comprehensive documentation for Tornado 4.5, detailing its web framework, HTTP servers and clients, asynchronous networking, coroutines and concurrency, and integration with other services. It highlights key features such as the routing system in tornado.routing, support for non-ASCII filenames in tornado.template, and improvements to the WebSocket module. The release notes outline changes like the introduction of a message size limit in tornado.websocket, enhanced coroutine performance, and compatibility updates for authentication and logging modules.
AI总结
《Tornado 4.5 Documentation》 是一个高性能异步网络框架的官方文档,适用于构建Web和TCP应用程序。以下是文档的核心内容总结: ### 1. 框架概述 Tornado 是一个异步、非阻塞的网络框架,适合处理高并发请求。其核心功能包括: - **Web框架**:提供 `RequestHandler` 和 `Application` 类,支持模板渲染、认证、安全和国际化。 - **HTTP服务器与客户端**:支持非阻塞HTTP服务器和异步HTTP客户端,提供HTTP头和URL操作工具。 - **异步网络功能**:通过 `IOLoop` 实现事件循环,支持非阻塞套接字和TCP客户端/服务器。 ### 2. 主要模块 - **Web模块**: - `tornado.web`:处理请求和应用配置。 - `tornado.routing`:提供灵活的路由系统。 - `tornado.auth`:支持第三方登录(如OpenID和OAuth)。 - `tornado.wsgi`:与其它Python框架和服务器的互操作性。 - **HTTP模块**: - `tornado.httpserver`:非阻塞HTTP服务器。 - `tornado.httpclient`:异步HTTP客户端,支持重定向和流式处理。 - **异步网络**: - `tornado.tcpclient` 和 `tornado.tcpserver`:支持非阻塞TCP连接和IPv6。 - `tornado.iostream`:封装非阻塞套接字,提供便捷的流操作。 - **协程与并发**: - `tornado.gen` 和 `tornado.concurrent`:简化异步代码,支持线程和 futures。 - `tornado.queues` 和 `tornado.locks`:提供队列和同步原语。 ### 3. 新功能与改进(Tornado 4.5) - **路由系统**:`tornado.routing` 提供更灵活的路由配置,取代旧版路由系统。 - **WebSocket改进**: - 默认限制消息大小为10MiB。 - 支持压缩(`permessage-deflate`)和心跳检测。 - 不再支持旧协议(draft 76),默认拒绝跨域连接。 - **Autoreload**: - 支持asyncio事件循环。 - 不再主动关闭文件描述符,依赖CLOEXEC标志。 - **HTTP客户端**: - 重定向处理优化:不再在重定向响应中运行回调。 - 支持 gzip 压缩,调整默认压缩级别为6。 - **模板改进**: - 支持非ASCII文件名。 - 新增`{% whitespace %}`指令,增强空白处理配置。 - **性能优化**: - 减少循环引用,降低内存使用。 - HTTP相关代码更一致,支持分块和gzip编码。 ### 4. 工具与实用功能 - **日志与调试**:`tornado.log` 提供彩色日志支持。 - **自动重载**:在开发环境中检测代码变化。 - **测试支持**:`tornado.testing` 提供异步测试框架。 ### 5. 兼容性与注意事项 - **向后兼容性**: - `tornado.concurrent.Future` 不再线程安全,建议使用 `concurrent.futures.Future`。 - 依赖 `certifi` 包提供CA证书。 - **重大变更**: - WebSocket默认关闭跨域连接。 - `simple_httpclient` 优化错误处理和超时机制。 ### 6. 其他资源 文档还提供FAQ、发行说明和示例代码,涵盖从Tornado 1.0到4.5的所有版本更新。 总结来看,Tornado 4.5在性能、功能和兼容性方面均有显著提升,特别在异步处理、WebSocket支持和HTTP客户端方面表现突出。
P1
P2
P3
P4
P5
P6
P7
下载文档到本地,方便使用
- 可预览页数已用完,剩余 326 页请下载阅读 -
文档评分
请文明评论,理性发言.