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 defcan be used in place of the@gen.coroutinedecorator. Inside a function defined withasync def, useawaitinstead ofyieldto wait on an asynchronous operation. Coroutines defined with async/await will be faster than those defined with@gen.coroutineandyield, but do not support some features includingCallback/Waitor the ability to yield a TwistedDeferred. See the users’ guide for more.The async/await keywords are also available when compiling with Cython in older 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 implements a mix of Python 3.2 and 3.3 features.
Installation¶
Tornado has several new dependencies:
ordereddicton Python 2.6,singledispatchon all Python versions prior to 3.4 (This was an optional dependency in prior versions of Tornado, and is now mandatory), andbackports_abc>=0.4on all versions prior to 3.5. These dependencies will be installed automatically when installing withpiporsetup.py install. These dependencies will not be required when running on Google App Engine.Binary wheels are provided for Python 3.5 on Windows (32 and 64 bit).
tornado.auth¶
New method
OAuth2Mixin.oauth2_requestcan be used to make authenticated requests with an access token.Now compatible with callbacks that have been compiled with Cython.
tornado.autoreload¶
Fixed an issue with the autoreload command-line wrapper in which imports would be incorrectly interpreted as relative.
tornado.curl_httpclient¶
Fixed parsing of multi-line headers.
allow_nonstandard_methods=Truenow bypasses body sanity checks, in the same way as insimple_httpclient.The
PATCHmethod now allows a body withoutallow_nonstandard_methods=True.
tornado.gen¶
WaitIteratornow supports theasync forstatement on Python 3.5.@gen.coroutinecan be applied to functions compiled with Cython. On python versions prior to 3.5, thebackports_abcpackage must be installed for this functionality.Multiandmulti_futureare deprecated and replaced by a unified functionmulti.
tornado.httpclient¶
tornado.httpclient.HTTPErroris now copyable with thecopymodule.
tornado.httpserver¶
Requests containing both
Content-LengthandTransfer-Encodingwill be treated as an error.
tornado.httputil¶
HTTPHeaderscan now be pickled and unpickled.
tornado.ioloop¶
IOLoop(make_current=True)now works as intended instead of raising an exception.The Twisted and asyncio IOLoop implementations now clear
current()when they exit, like the standard IOLoops.IOLoop.add_callbackis faster in the single-threaded case.IOLoop.add_callbackno longer raises an error when called on a closed IOLoop, but the callback will not be invoked.
tornado.iostream¶
Coroutine-style usage of
IOStreamnow converts most errors intoStreamClosedError, which has the effect of reducing log noise from exceptions that are outside the application’s control (especially SSL errors).StreamClosedErrornow has areal_errorattribute which indicates why the stream was closed. It is the same as theerrorattribute ofIOStreambut may be more easily accessible than theIOStreamitself.Improved error handling in
read_until_close.Logging is less noisy when an SSL server is port scanned.
EINTRis now handled on all reads.
tornado.locale¶
tornado.locale.load_translationsnow accepts encodings other than UTF-8. UTF-16 and UTF-8 will be detected automatically if a BOM is present; for other encodingsload_translationshas anencodingparameter.
tornado.locks¶
tornado.log¶
A new time-based log rotation mode is available with
--log_rotate_mode=time,--log-rotate-when, andlog-rotate-interval.
tornado.netutil¶
bind_socketsnow supportsSO_REUSEPORTwith thereuse_port=Trueargument.
tornado.options¶
Dashes and underscores are now fully interchangeable in option names.
tornado.queues¶
Queuenow supports theasync forstatement on Python 3.5.
tornado.simple_httpclient¶
When following redirects,
streaming_callbackandheader_callbackwill no longer be run on the redirect responses (only the final non-redirect).Responses containing both
Content-LengthandTransfer-Encodingwill be treated as an error.
tornado.template¶
tornado.template.ParseErrornow includes the filename in addition to line number.Whitespace handling has become more configurable. The
Loaderconstructor now has awhitespaceargument, there is a newtemplate_whitespaceApplicationsetting, and there is a new{% whitespace %}template directive. All of these options take a mode name defined in thetornado.template.filter_whitespacefunction. The default mode issingle, which is the same behavior as prior versions of Tornado.Non-ASCII filenames are now supported.
tornado.testing¶
ExpectLogobjects now have a booleanlogged_stackattribute to make it easier to test whether an exception stack trace was logged.
tornado.web¶
The hard limit of 4000 bytes per outgoing header has been removed.
StaticFileHandlerreturns the correctContent-Typefor files with.gz,.bz2, and.xzextensions.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
StaticFileHandlerwith apathof/.tornado.web.HTTPErroris now copyable with thecopymodule.The exception
Finishnow accepts an argument which will be passed to the methodRequestHandler.finish.New
Applicationsettingxsrf_cookie_kwargscan be used to set additional attributes such assecureorhttponlyon the XSRF cookie.Application.listennow returns theHTTPServerit created.
tornado.websocket¶
Fixed handling of continuation frames when compression is enabled.