What’s new in the next release of Tornado¶
In progress¶
Highlights¶
- If a
Futurecontains an exception but that exception is never examined or re-raised (e.g. by yielding theFuture), a stack trace will be logged when theFutureis garbage-collected. - New class
tornado.gen.WaitIteratorprovides a way to iterate overFuturesin the order they resolve. - The
tornado.websocketmodule now supports compression via the “permessage-deflate” extension. OverrideWebSocketHandler.get_compression_optionsto enable on the server side, and use thecompression_optionskeyword argument towebsocket_connecton the client side. - When the appropriate packages are installed, it is possible to yield
asyncio.Futureor TwistedDeferedobjects in Tornado coroutines.
Backwards-compatibility notes¶
HTTPServernow callsstart_requestwith the correct arguments. This change is backwards-incompatible, afffecting any application which implementedHTTPServerConnectionDelegateby following the example ofApplicationinstead of the documented method signatures.
tornado.curl_httpclient¶
tornado.curl_httpclientnow supports request bodies forPATCHand custom methods.tornado.curl_httpclientnow supports resubmitting bodies after following redirects for methods other thanPOST.curl_httpclientnow runs the streaming and header callbacks on the IOLoop.tornado.curl_httpclientnow uses its own logger for debug output so it can be filtered more easily.
tornado.gen¶
- New class
tornado.gen.WaitIteratorprovides a way to iterate overFuturesin the order they resolve. - When the
singledispatchlibrary is available (standard on Python 3.4, available viapip install singledispatchon older versions), theconvert_yieldedfunction can be used to make other kinds of objects yieldable in coroutines. - New function
tornado.gen.sleepis a coroutine-friendly analogue totime.sleep. gen.enginenow correctly captures the stack context for its callbacks.
tornado.httpclient¶
tornado.httpclient.HTTPRequestaccepts a new argumentraise_error=Falseto suppress the default behavior of raising an error for non-200 response codes.
tornado.httpserver¶
HTTPServernow callsstart_requestwith the correct arguments. This change is backwards-incompatible, afffecting any application which implementedHTTPServerConnectionDelegateby following the example ofApplicationinstead of the documented method signatures.HTTPServernow tolerates extra newlines which are sometimes inserted between requests on keep-alive connections.HTTPServercan now use keep-alive connections after a request with a chunked body.HTTPServernow always reportsHTTP/1.1instead of echoing the request version.
tornado.httputil¶
- New function
tornado.httputil.split_host_and_portfor parsing thenetlocportion of URLs. - The
contextargument toHTTPServerRequestis now optional, and if a context is supplied theremote_ipattribute is also optional. HTTPServerRequest.bodyis now always a byte string (previously the default empty body would be a unicode string on python 3).- Header parsing now works correctly when newline-like unicode characters are present.
- Header parsing again supports both CRLF and bare LF line separators.
- Malformed
multipart/form-databodies will always be logged quietly instead of raising an unhandled exception; previously the behavior was inconsistent depending on the exact error.
tornado.ioloop¶
- The
kqueueandselectIOLoop implementations now report writeability correctly, fixing flow control in IOStream. - When a new
IOLoopis created, it automatically becomes “current” for the thread if there is not already a current instance. - New method
PeriodicCallback.is_runningcan be used to see whether thePeriodicCallbackhas been started.
tornado.iostream¶
IOStream.start_tlsnow uses theserver_hostnameparameter for certificate validation.SSLIOStreamwill no longer consume 100% CPU after certain error conditions.SSLIOStreamno longer logsEBADFerrors during the handshake as they can result from nmap scans in certain modes.
tornado.options¶
parse_config_filenow always decodes the config file as utf8 on Python 3.tornado.options.definemore accurately finds the module defining the option.
tornado.platform.asyncio¶
- It is now possible to yield
asyncio.Futureobjects in coroutines when thesingledispatchlibrary is available andtornado.platform.asynciohas been imported. - New methods
tornado.platform.asyncio.to_tornado_futureandto_asyncio_futureconvert between the two libraries’Futureclasses.
tornado.platform.twisted¶
- It is now possible to yield
Deferredobjects in coroutines when thesingledispatchlibrary is available andtornado.platform.twistedhas been imported.
tornado.tcpclient¶
TCPClientwill no longer raise an exception due to an ill-timed timeout.
tornado.tcpserver¶
TCPServerno longer ignores itsread_chunk_sizeargument.
tornado.testing¶
AsyncTestCasehas better support for multiple exceptions. Previously it would silently swallow all but the last; now it raises the first and logs all the rest.AsyncTestCasenow cleans upSubprocessstate ontearDownwhen necessary.
tornado.web¶
- The
asynchronousdecorator now understandsconcurrent.futures.Futurein addition totornado.concurrent.Future. StaticFileHandlerno longer logs a stack trace if the connection is closed while sending the file.RequestHandler.send_errornow supports areasonkeyword argument, similar totornado.web.HTTPError.RequestHandler.localenow has a property setter.Application.add_handlershostname matching now works correctly with IPv6 literals.- Redirects for the
Applicationdefault_hostsetting now match the request protocol instead of redirecting HTTPS to HTTP. - Malformed
_xsrfcookies are now ignored instead of causing uncaught exceptions. Application.start_requestnow has the same signature asHTTPServerConnectionDelegate.start_request.
tornado.websocket¶
- The
tornado.websocketmodule now supports compression via the “permessage-deflate” extension. OverrideWebSocketHandler.get_compression_optionsto enable on the server side, and use thecompression_optionskeyword argument towebsocket_connecton the client side. WebSocketHandlerno longer logs stack traces when the connection is closed.WebSocketHandler.opennow accepts*args, **kwfor consistency withRequestHandler.getand related methods.- The
Sec-WebSocket-Versionheader now includes all supported versions. websocket_connectnow has aon_message_callbackkeyword argument for callback-style use withoutread_message().