What’s new in Tornado 3.2¶
Jan 14, 2014¶
Installation¶
- Tornado now depends on the backports.ssl_match_hostname when
running on Python 2. This will be installed automatically when using
piporeasy_install - Tornado now includes an optional C extension module, which greatly improves performance of websockets. This extension will be built automatically if a C compiler is found at install time.
New modules¶
- The
tornado.platform.asynciomodule provides integration with theasynciomodule introduced in Python 3.4 (also available for Python 3.3 withpip install asyncio).
tornado.auth¶
- Added
GoogleOAuth2Mixinsupport authentication to Google services with OAuth 2 instead of OpenID and OAuth 1. FacebookGraphMixinhas been updated to use the current Facebook login URL, which saves a redirect.
tornado.concurrent¶
TracebackFuturenow accepts atimeoutkeyword argument (although it is still incorrect to use a non-zero timeout in non-blocking code).
tornado.curl_httpclient¶
tornado.curl_httpclientnow works on Python 3 with the soon-to-be-released pycurl 7.19.3, which will officially support Python 3 for the first time. Note that there are some unofficial Python 3 ports of pycurl (Ubuntu has included one for its past several releases); these are not supported for use with Tornado.
tornado.escape¶
xhtml_escapenow escapes apostrophes as well.tornado.escape.utf8,to_unicode, andnative_strnow raiseTypeErrorinstead ofAssertionErrorwhen given an invalid value.
tornado.gen¶
- Coroutines may now yield dicts in addition to lists to wait for multiple tasks in parallel.
- Improved performance of
tornado.genwhen yielding aFuturethat is already done.
tornado.httpclient¶
tornado.httpclient.HTTPRequestnow uses property setters so that setting attributes after construction applies the same conversions as__init__(e.g. converting the body attribute to bytes).
tornado.httpserver¶
- Malformed
x-www-form-urlencodedrequest bodies will now log a warning and continue instead of causing the request to fail (similar to the existing handling of malformedmultipart/form-databodies. This is done mainly because some libraries send this content type by default even when the data is not form-encoded. - Fix some error messages for unix sockets (and other non-IP sockets)
tornado.ioloop¶
IOLoopnow useshandle_callback_exceptionconsistently for error logging.IOLoopnow frees callback objects earlier, reducing memory usage while idle.IOLoopwill no longer calllogging.basicConfigif there is a handler defined for the root logger or for thetornadoortornado.applicationloggers (previously it only looked at the root logger).
tornado.iostream¶
IOStreamnow recognizesECONNABORTEDerror codes in more places (which was mainly an issue on Windows).IOStreamnow frees memory earlier if a connection is closed while there is data in the write buffer.PipeIOStreamnow handlesEAGAINerror codes correctly.SSLIOStreamnow initiates the SSL handshake automatically without waiting for the application to try and read or write to the connection.- Swallow a spurious exception from
set_nodelaywhen a connection has been reset.
tornado.locale¶
Locale.format_dateno longer forces the use of absolute dates in Russian.
tornado.log¶
- Fix an error from
tornado.log.enable_pretty_loggingwhensys.stderrdoes not have anisattymethod. tornado.log.LogFormatternow accepts keyword argumentsfmtanddatefmt.
tornado.netutil¶
is_valid_ip(and thereforeHTTPRequest.remote_ip) now rejects empty strings.- Synchronously using
ThreadedResolverat import time to resolve a unicode hostname no longer deadlocks.
tornado.platform.twisted¶
TwistedResolvernow has better error handling.
tornado.process¶
Subprocessno longer leaks file descriptors ifsubprocess.Popenfails.
tornado.simple_httpclient¶
simple_httpclientnow applies theconnect_timeoutto requests that are queued and have not yet started.- On Python 2.6,
simple_httpclientnow uses TLSv1 instead of SSLv3. simple_httpclientnow enforces the connect timeout during DNS resolution.- The embedded
ca-certificates.crtfile has been updated with the current Mozilla CA list.
tornado.web¶
StaticFileHandlerno longer fails if the client requests aRangethat is larger than the entire file (Facebook has a crawler that does this).RequestHandler.on_connection_closenow works correctly on subsequent requests of a keep-alive connection.- New application setting
default_handler_classcan be used to easily set up custom 404 pages. - New application settings
autoreload,compiled_template_cache,static_hash_cache, andserve_tracebackcan be used to control individual aspects of debug mode. - New methods
RequestHandler.get_query_argumentandRequestHandler.get_body_argumentand new attributesHTTPRequest.query_argumentsandHTTPRequest.body_argumentsallow access to arguments without intermingling those from the query string with those from the request body. RequestHandler.decode_argumentand related methods now raise anHTTPError(400)instead ofUnicodeDecodeErrorwhen the argument could not be decoded.RequestHandler.clear_all_cookiesnow acceptsdomainandpatharguments, just likeclear_cookie.- It is now possible to specify handlers by name when using the
URLSpecclass. Applicationnow accepts 4-tuples to specify thenameparameter (which previously required constructing aURLSpecobject instead of a tuple).- Fixed an incorrect error message when handler methods return a value other than None or a Future.
- Exceptions will no longer be logged twice when using both
@asynchronousand@gen.coroutine
tornado.websocket¶
WebSocketHandler.write_messagenow raisesWebSocketClosedErrorinstead ofAttributeErrorwhen the connection has been closed.websocket_connectnow accepts preconstructedHTTPRequestobjects.- Fix a bug with
WebSocketHandlerwhen used with some proxies that unconditionally modify theConnectionheader. websocket_connectnow returns an error immediately for refused connections instead of waiting for the timeout.WebSocketClientConnectionnow has aclosemethod.
tornado.wsgi¶
WSGIContainernow calls the iterable’sclose()method even if an error is raised, in compliance with the spec.