### Navigation
- [index](# "General Index")
- [modules](# "Python Module Index") |
- [next](# "What鈥檚 new in Tornado 4.0.2") |
- [previous](# "What鈥檚 new in Tornado 4.2") |
- [Tornado 4.4.dev1 documentation](#) »
- [Release notes](#) »
# What's new in Tornado 4.1
### Feb 7, 2015
### Highlights
- If a [`Future`](# "tornado.concurrent.Future") contains an exception but that exception is neverexamined or re-raised (e.g. by yielding the [`Future`](# "tornado.concurrent.Future")), a stacktrace will be logged when the [`Future`](# "tornado.concurrent.Future") is garbage-collected.
- New class [`tornado.gen.WaitIterator`](# "tornado.gen.WaitIterator") provides a way to iterateover `Futures` in the order they resolve.
- The [`tornado.websocket`](# "tornado.websocket") module now supports compression via the“permessage-deflate” extension. Override[`WebSocketHandler.get_compression_options`](# "tornado.websocket.WebSocketHandler.get_compression_options") to enable on the serverside, and use the `compression_options` keyword argument to[`websocket_connect`](# "tornado.websocket.websocket_connect") on the client side.
- When the appropriate packages are installed, it is possible to yield[`asyncio.Future`](https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future] or Twisted `Defered` objects in Tornado coroutines.
### Backwards-compatibility notes
- [`HTTPServer`](# "tornado.httpserver.HTTPServer") now calls `start_request` with the correctarguments. This change is backwards-incompatible, afffecting anyapplication which implemented [`HTTPServerConnectionDelegate`](# "tornado.httputil.HTTPServerConnectionDelegate") byfollowing the example of [`Application`](# "tornado.web.Application") instead of the documentedmethod signatures.
### [`tornado.concurrent`](# "tornado.concurrent")
- If a [`Future`](# "tornado.concurrent.Future") contains an exception but that exception is neverexamined or re-raised (e.g. by yielding the [`Future`](# "tornado.concurrent.Future")), a stacktrace will be logged when the [`Future`](# "tornado.concurrent.Future") is garbage-collected.
- [`Future`](# "tornado.concurrent.Future") now catches and logs exceptions in its callbacks.
### `tornado.curl_httpclient`
- `tornado.curl_httpclient` now supports request bodies for `PATCH`and custom methods.
- `tornado.curl_httpclient` now supports resubmitting bodies afterfollowing redirects for methods other than `POST`.
- `curl_httpclient` now runs the streaming and header callbacks onthe IOLoop.
- `tornado.curl_httpclient` now uses its own logger for debug outputso it can be filtered more easily.
### [`tornado.gen`](# "tornado.gen")
- New class [`tornado.gen.WaitIterator`](# "tornado.gen.WaitIterator") provides a way to iterateover `Futures` in the order they resolve.
- When the [`singledispatch`](https://docs.python.org/3.4/library/functools.html#functools.singledispatch "(in Python v3.4)") [https://docs.python.org/3.4/library/functools.html#functools.singledispatch] library is available (standard onPython 3.4, available via `pip install singledispatch` on older versions),the [`convert_yielded`](# "tornado.gen.convert_yielded") function can be used to make other kinds of objectsyieldable in coroutines.
- New function [`tornado.gen.sleep`](# "tornado.gen.sleep") is a coroutine-friendlyanalogue to [`time.sleep`](https://docs.python.org/3.4/library/time.html#time.sleep "(in Python v3.4)") [https://docs.python.org/3.4/library/time.html#time.sleep].
- [`gen.engine`](# "tornado.gen.engine") now correctly captures the stack context for its callbacks.
### [`tornado.httpclient`](# "tornado.httpclient")
- [`tornado.httpclient.HTTPRequest`](# "tornado.httpclient.HTTPRequest") accepts a new argument`raise_error=False` to suppress the default behavior of raising anerror for non-200 response codes.
### [`tornado.httpserver`](# "tornado.httpserver")
- [`HTTPServer`](# "tornado.httpserver.HTTPServer") now calls `start_request` with the correctarguments. This change is backwards-incompatible, afffecting anyapplication which implemented [`HTTPServerConnectionDelegate`](# "tornado.httputil.HTTPServerConnectionDelegate") byfollowing the example of [`Application`](# "tornado.web.Application") instead of the documentedmethod signatures.
- [`HTTPServer`](# "tornado.httpserver.HTTPServer") now tolerates extra newlines which are sometimes insertedbetween requests on keep-alive connections.
- [`HTTPServer`](# "tornado.httpserver.HTTPServer") can now use keep-alive connections after a requestwith a chunked body.
- [`HTTPServer`](# "tornado.httpserver.HTTPServer") now always reports `HTTP/1.1` instead of echoingthe request version.
### [`tornado.httputil`](# "tornado.httputil")
- New function [`tornado.httputil.split_host_and_port`](# "tornado.httputil.split_host_and_port") for parsingthe `netloc` portion of URLs.
- The `context` argument to [`HTTPServerRequest`](# "tornado.httputil.HTTPServerRequest") is now optional,and if a context is supplied the `remote_ip` attribute is also optional.
- [`HTTPServerRequest.body`](# "tornado.httputil.HTTPServerRequest.body") is now always a byte string (previously the defaultempty body would be a unicode string on python 3).
- Header parsing now works correctly when newline-like unicode charactersare present.
- Header parsing again supports both CRLF and bare LF line separators.
- Malformed `multipart/form-data` bodies will always be loggedquietly instead of raising an unhandled exception; previouslythe behavior was inconsistent depending on the exact error.
### [`tornado.ioloop`](# "tornado.ioloop")
- The `kqueue` and `select` IOLoop implementations now reportwriteability correctly, fixing flow control in IOStream.
- When a new [`IOLoop`](# "tornado.ioloop.IOLoop") is created, it automatically becomes “current”for the thread if there is not already a current instance.
- New method [`PeriodicCallback.is_running`](# "tornado.ioloop.PeriodicCallback.is_running") can be used to seewhether the [`PeriodicCallback`](# "tornado.ioloop.PeriodicCallback") has been started.
### [`tornado.iostream`](# "tornado.iostream")
- [`IOStream.start_tls`](# "tornado.iostream.IOStream.start_tls") now uses the `server_hostname` parameterfor certificate validation.
- [`SSLIOStream`](# "tornado.iostream.SSLIOStream") will no longer consume 100% CPU after certain error conditions.
- [`SSLIOStream`](# "tornado.iostream.SSLIOStream") no longer logs `EBADF` errors during the handshake as theycan result from nmap scans in certain modes.
### [`tornado.options`](# "tornado.options")
- [`parse_config_file`](# "tornado.options.parse_config_file") now always decodes the configfile as utf8 on Python 3.
- [`tornado.options.define`](# "tornado.options.define") more accurately finds the module defining theoption.
### `tornado.platform.asyncio`
- It is now possible to yield `asyncio.Future` objects in coroutineswhen the [`singledispatch`](https://docs.python.org/3.4/library/functools.html#functools.singledispatch "(in Python v3.4)") [https://docs.python.org/3.4/library/functools.html#functools.singledispatch] library is available and`tornado.platform.asyncio` has been imported.
- New methods [`tornado.platform.asyncio.to_tornado_future`](# "tornado.platform.asyncio.to_tornado_future") and[`to_asyncio_future`](# "tornado.platform.asyncio.to_asyncio_future") convert betweenthe two libraries' [`Future`](# "tornado.concurrent.Future") classes.
### `tornado.platform.twisted`
- It is now possible to yield `Deferred` objects in coroutineswhen the [`singledispatch`](https://docs.python.org/3.4/library/functools.html#functools.singledispatch "(in Python v3.4)") [https://docs.python.org/3.4/library/functools.html#functools.singledispatch] library is available and`tornado.platform.twisted` has been imported.
### [`tornado.tcpclient`](# "tornado.tcpclient")
- [`TCPClient`](# "tornado.tcpclient.TCPClient") will no longer raise an exception due to an ill-timedtimeout.
### [`tornado.tcpserver`](# "tornado.tcpserver")
- [`TCPServer`](# "tornado.tcpserver.TCPServer") no longer ignores its `read_chunk_size` argument.
### [`tornado.testing`](# "tornado.testing")
- [`AsyncTestCase`](# "tornado.testing.AsyncTestCase") has better support for multiple exceptions. Previouslyit would silently swallow all but the last; now it raises the firstand logs all the rest.
- [`AsyncTestCase`](# "tornado.testing.AsyncTestCase") now cleans up [`Subprocess`](# "tornado.process.Subprocess") state on `tearDown` whennecessary.
### [`tornado.web`](# "tornado.web")
- The [`asynchronous`](# "tornado.web.asynchronous") decorator now understands [`concurrent.futures.Future`](https://docs.python.org/3.4/library/concurrent.futures.html#concurrent.futures.Future "(in Python v3.4)") [https://docs.python.org/3.4/library/concurrent.futures.html#concurrent.futures.Future]in addition to [`tornado.concurrent.Future`](# "tornado.concurrent.Future").
- [`StaticFileHandler`](# "tornado.web.StaticFileHandler") no longer logs a stack trace if the connection isclosed while sending the file.
- [`RequestHandler.send_error`](# "tornado.web.RequestHandler.send_error") now supports a `reason` keywordargument, similar to [`tornado.web.HTTPError`](# "tornado.web.HTTPError").
- [`RequestHandler.locale`](# "tornado.web.RequestHandler.locale") now has a property setter.
- [`Application.add_handlers`](# "tornado.web.Application.add_handlers") hostname matching now works correctly withIPv6 literals.
- Redirects for the [`Application`](# "tornado.web.Application")`default_host` setting now matchthe request protocol instead of redirecting HTTPS to HTTP.
- Malformed `_xsrf` cookies are now ignored instead of causinguncaught exceptions.
- `Application.start_request` now has the same signature as[`HTTPServerConnectionDelegate.start_request`](# "tornado.httputil.HTTPServerConnectionDelegate.start_request").
### [`tornado.websocket`](# "tornado.websocket")
- The [`tornado.websocket`](# "tornado.websocket") module now supports compression via the“permessage-deflate” extension. Override[`WebSocketHandler.get_compression_options`](# "tornado.websocket.WebSocketHandler.get_compression_options") to enable on the serverside, and use the `compression_options` keyword argument to[`websocket_connect`](# "tornado.websocket.websocket_connect") on the client side.
- [`WebSocketHandler`](# "tornado.websocket.WebSocketHandler") no longer logs stack traces when the connectionis closed.
- [`WebSocketHandler.open`](# "tornado.websocket.WebSocketHandler.open") now accepts `*args, **kw` for consistencywith `RequestHandler.get` and related methods.
- The `Sec-WebSocket-Version` header now includes all supported versions.
- [`websocket_connect`](# "tornado.websocket.websocket_connect") now has a `on_message_callback` keyword argumentfor callback-style use without `read_message()`.
© Copyright 2009-2016, The Tornado Authors. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.
- User's guide
- Introduction
- Asynchronous and non-Blocking I/O
- Coroutines
- Queue example - a concurrent web spider
- Structure of a Tornado web application
- Templates and UI
- Authentication and security
- Running and deploying
- Web framework
- tornado.web — RequestHandler and Application classes
- tornado.template — Flexible output generation
- tornado.escape — Escaping and string manipulation
- tornado.locale — Internationalization support
- tornado.websocket — Bidirectional communication to the browser
- HTTP servers and clients
- tornado.httpserver — Non-blocking HTTP server
- tornado.httpclient — Asynchronous HTTP client
- tornado.httputil — Manipulate HTTP headers and URLs
- tornado.http1connection – HTTP/1.x client/server implementation
- Asynchronous networking
- tornado.ioloop — Main event loop
- tornado.iostream — Convenient wrappers for non-blocking sockets
- tornado.netutil — Miscellaneous network utilities
- tornado.tcpclient — IOStream connection factory
- tornado.tcpserver — Basic IOStream-based TCP server
- Coroutines and concurrency
- tornado.gen — Simplify asynchronous code
- tornado.concurrent — Work with threads and futures
- tornado.locks – Synchronization primitives
- tornado.queues – Queues for coroutines
- tornado.process — Utilities for multiple processes
- Integration with other services
- tornado.auth — Third-party login with OpenID and OAuth
- tornado.wsgi — Interoperability with other Python frameworks and servers
- tornado.platform.asyncio — Bridge between asyncio and Tornado
- tornado.platform.caresresolver — Asynchronous DNS Resolver using C-Ares
- tornado.platform.twisted — Bridges between Twisted and Tornado
- Utilities
- tornado.autoreload — Automatically detect code changes in development
- tornado.log — Logging support
- tornado.options — Command-line parsing
- tornado.stack_context — Exception handling across asynchronous callbacks
- tornado.testing — Unit testing support for asynchronous code
- tornado.util — General-purpose utilities
- Frequently Asked Questions
- Release notes
- What's new in Tornado 4.3
- What's new in Tornado 4.2.1
- What's new in Tornado 4.2
- What's new in Tornado 4.1
- What's new in Tornado 4.0.2
- What's new in Tornado 4.0.1
- What's new in Tornado 4.0
- What's new in Tornado 3.2.2
- What's new in Tornado 3.2.1
- What's new in Tornado 3.2
- What's new in Tornado 3.1.1
- What's new in Tornado 3.1
- What's new in Tornado 3.0.2
- What's new in Tornado 3.0.1
- What's new in Tornado 3.0
- What's new in Tornado 2.4.1
- What's new in Tornado 2.4
- What's new in Tornado 2.3
- What's new in Tornado 2.2.1
- What's new in Tornado 2.2
- What's new in Tornado 2.1.1
- What's new in Tornado 2.1
- What's new in Tornado 2.0
- What's new in Tornado 1.2.1
- What's new in Tornado 1.2
- What's new in Tornado 1.1.1
- What's new in Tornado 1.1
- What's new in Tornado 1.0.1
- What's new in Tornado 1.0