企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
### Navigation - [index](# "General Index") - [modules](# "Python Module Index") | - [next](# "What鈥檚 new in Tornado 4.2.1") | - [previous](# "Release notes") | - [Tornado 4.4.dev1 documentation](#) » - [Release notes](#) » # What's new in Tornado 4.3 ### Nov 6, 2015 ### Highlights - The new async/await keywords in Python 3.5 are supported. In most cases,`async def` can be used in place of the `@gen.coroutine` decorator.Inside a function defined with `async def`, use `await` instead of`yield` to wait on an asynchronous operation. Coroutines defined withasync/await will be faster than those defined with `@gen.coroutine` and`yield`, but do not support some features including [`Callback`](# "tornado.gen.Callback")/[`Wait`](# "tornado.gen.Wait") orthe ability to yield a Twisted `Deferred`. See [the users'guide](#) for more. - The async/await keywords are also available when compiling with Cython inolder versions of Python. ### Deprecation notice - This will be the last release of Tornado to support Python 2.6 or 3.2.Note that PyPy3 will continue to be supported even though it implementsa mix of Python 3.2 and 3.3 features. ### Installation - Tornado has several new dependencies: `ordereddict` on Python 2.6,`singledispatch` on all Python versions prior to 3.4 (This was anoptional dependency in prior versions of Tornado, and is nowmandatory), and `backports_abc>=0.4` on all versions prior to3.5. These dependencies will be installed automatically when installingwith `pip` or `setup.py install`. These dependencies will notbe required when running on Google App Engine. - Binary wheels are provided for Python 3.5 on Windows (32 and 64 bit). ### [`tornado.auth`](# "tornado.auth") - New method [`OAuth2Mixin.oauth2_request`](# "tornado.auth.OAuth2Mixin.oauth2_request") can be used to make authenticatedrequests with an access token. - Now compatible with callbacks that have been compiled with Cython. ### [`tornado.autoreload`](# "tornado.autoreload") - Fixed an issue with the autoreload command-line wrapper in whichimports would be incorrectly interpreted as relative. ### [`tornado.curl_httpclient`](# "tornado.curl_httpclient") - Fixed parsing of multi-line headers. - `allow_nonstandard_methods=True` now bypasses body sanity checks,in the same way as in `simple_httpclient`. - The `PATCH` method now allows a body without`allow_nonstandard_methods=True`. ### [`tornado.gen`](# "tornado.gen") - [`WaitIterator`](# "tornado.gen.WaitIterator") now supports the `async for` statement on Python 3.5. - `@gen.coroutine` can be applied to functions compiled with Cython.On python versions prior to 3.5, the `backports_abc` package mustbe installed for this functionality. - `Multi` and [`multi_future`](# "tornado.gen.multi_future") are deprecated and replaced bya unified function [`multi`](# "tornado.gen.multi"). ### [`tornado.httpclient`](# "tornado.httpclient") - [`tornado.httpclient.HTTPError`](# "tornado.httpclient.HTTPError") is now copyable with the [`copy`](https://docs.python.org/3.4/library/copy.html#module-copy "(in Python v3.4)") [https://docs.python.org/3.4/library/copy.html#module-copy] module. ### [`tornado.httpserver`](# "tornado.httpserver") - Requests containing both `Content-Length` and `Transfer-Encoding`will be treated as an error. ### [`tornado.httputil`](# "tornado.httputil") - [`HTTPHeaders`](# "tornado.httputil.HTTPHeaders") can now be pickled and unpickled. ### [`tornado.ioloop`](# "tornado.ioloop") - `IOLoop(make_current=True)` now works as intended insteadof raising an exception. - The Twisted and asyncio IOLoop implementations now clear`current()` when they exit, like the standard IOLoops. - [`IOLoop.add_callback`](# "tornado.ioloop.IOLoop.add_callback") is faster in the single-threaded case. - [`IOLoop.add_callback`](# "tornado.ioloop.IOLoop.add_callback") no longer raises an error when called ona closed IOLoop, but the callback will not be invoked. ### [`tornado.iostream`](# "tornado.iostream") - Coroutine-style usage of [`IOStream`](# "tornado.iostream.IOStream") now converts most errors into[`StreamClosedError`](# "tornado.iostream.StreamClosedError"), which has the effect of reducing log noise fromexceptions that are outside the application's control (especiallySSL errors). - [`StreamClosedError`](# "tornado.iostream.StreamClosedError") now has a `real_error` attribute which indicateswhy the stream was closed. It is the same as the `error` attribute of[`IOStream`](# "tornado.iostream.IOStream") but may be more easily accessible than the [`IOStream`](# "tornado.iostream.IOStream") itself. - Improved error handling in [`read_until_close`](# "tornado.iostream.BaseIOStream.read_until_close"). - Logging is less noisy when an SSL server is port scanned. - `EINTR` is now handled on all reads. ### [`tornado.locale`](# "tornado.locale") - [`tornado.locale.load_translations`](# "tornado.locale.load_translations") now accepts encodings other thanUTF-8. UTF-16 and UTF-8 will be detected automatically if a BOM ispresent; for other encodings [`load_translations`](# "tornado.locale.load_translations") has an `encoding`parameter. ### [`tornado.locks`](# "tornado.locks") - [`Lock`](# "tornado.locks.Lock") and [`Semaphore`](# "tornado.locks.Semaphore") now support the `async with` statement onPython 3.5. ### [`tornado.log`](# "tornado.log") - A new time-based log rotation mode is available with`--log_rotate_mode=time`, `--log-rotate-when`, and`log-rotate-interval`. ### [`tornado.netutil`](# "tornado.netutil") - [`bind_sockets`](# "tornado.netutil.bind_sockets") now supports `SO_REUSEPORT` with the `reuse_port=True`argument. ### [`tornado.options`](# "tornado.options") - Dashes and underscores are now fully interchangeable in option names. ### [`tornado.queues`](# "tornado.queues") - [`Queue`](# "tornado.queues.Queue") now supports the `async for` statement on Python 3.5. ### [`tornado.simple_httpclient`](# "tornado.simple_httpclient") - When following redirects, `streaming_callback` and`header_callback` will no longer be run on the redirect responses(only the final non-redirect). - Responses containing both `Content-Length` and `Transfer-Encoding`will be treated as an error. ### [`tornado.template`](# "tornado.template") - [`tornado.template.ParseError`](# "tornado.template.ParseError") now includes the filename in addition toline number. - Whitespace handling has become more configurable. The [`Loader`](# "tornado.template.Loader")constructor now has a `whitespace` argument, there is a new`template_whitespace`[`Application`](# "tornado.web.Application") setting, and there is a new`{% whitespace %}` template directive. All of these options takea mode name defined in the [`tornado.template.filter_whitespace`](# "tornado.template.filter_whitespace") function.The default mode is `single`, which is the same behavior as priorversions of Tornado. - Non-ASCII filenames are now supported. ### [`tornado.testing`](# "tornado.testing") - [`ExpectLog`](# "tornado.testing.ExpectLog") objects now have a boolean `logged_stack` attribute tomake it easier to test whether an exception stack trace was logged. ### [`tornado.web`](# "tornado.web") - The hard limit of 4000 bytes per outgoing header has been removed. - [`StaticFileHandler`](# "tornado.web.StaticFileHandler") returns the correct `Content-Type` for fileswith `.gz`, `.bz2`, and `.xz` extensions. - Responses smaller than 1000 bytes will no longer be compressed. - The default gzip compression level is now 6 (was 9). - Fixed a regression in Tornado 4.2.1 that broke [`StaticFileHandler`](# "tornado.web.StaticFileHandler")with a `path` of `/`. - [`tornado.web.HTTPError`](# "tornado.web.HTTPError") is now copyable with the [`copy`](https://docs.python.org/3.4/library/copy.html#module-copy "(in Python v3.4)") [https://docs.python.org/3.4/library/copy.html#module-copy] module. - The exception [`Finish`](# "tornado.web.Finish") now accepts an argument which will be passed tothe method [`RequestHandler.finish`](# "tornado.web.RequestHandler.finish"). - New [`Application`](# "tornado.web.Application") setting `xsrf_cookie_kwargs` can be used to setadditional attributes such as `secure` or `httponly` on theXSRF cookie. - [`Application.listen`](# "tornado.web.Application.listen") now returns the [`HTTPServer`](# "tornado.httpserver.HTTPServer") it created. ### [`tornado.websocket`](# "tornado.websocket") - Fixed handling of continuation frames when compression is enabled. © Copyright 2009-2016, The Tornado Authors. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.