What’s new in Tornado 5.1¶
July 12, 2018¶
Tornado 6.0 will drop support for Python 2.7 and 3.4. The minimum supported Python version will be 3.5.2.
tornado.stack_contextmodule is deprecated and will be removed in Tornado 6.0. The reason for this is that it is not feasible to provide this module’s semantics in the presence of
async defnative coroutines.
ExceptionStackContextis mainly obsolete thanks to coroutines.
StackContextlacks a direct replacement although the new
contextvarspackage (in the Python standard library beginning in Python 3.7) may be an alternative.
Callback-oriented code often relies on
ExceptionStackContextto handle errors and prevent leaked connections. In order to avoid the risk of silently introducing subtle leaks (and to consolidate all of Tornado’s interfaces behind the coroutine pattern),
callbackarguments throughout the package are deprecated and will be removed in version 6.0. All functions that had a
callbackargument removed now return a
Futurewhich should be used instead.
Where possible, deprecation warnings are emitted when any of these deprecated interfaces is used. However, Python does not display deprecation warnings by default. To prepare your application for Tornado 6.0, run Python with the
-Wdargument or set the environment variable
d. If your application runs on Python 3 without deprecation warnings, it should be able to move to Tornado 6.0 without disruption.
OAuthMixin._oauth_get_user_futuremay now be a native coroutine.
callbackarguments in this package are deprecated and will be removed in 6.0. Use the coroutine interfaces instead.
OAuthMixin._oauth_get_usermethod is deprecated and will be removed in 6.0. Override
The command-line autoreload wrapper is now preserved if an internal autoreload fires.
The command-line wrapper no longer starts duplicated processes on windows when combined with internal autoreload.
Futureobjects that are compatible with
run_on_executoris deprecated and will be removed in 6.0.
return_futureis deprecated and will be removed in 6.0.
Some older portions of this module are deprecated and will be removed in 6.0. This includes
Functions decorated with
@gen.coroutinewill no longer accept
callbackarguments in 6.0.
The behavior of
raise_error=Falseis changing in 6.0. Currently it suppresses all errors; in 6.0 it will only suppress the errors raised due to completed responses with non-200 status codes.
AsyncHTTPClient.fetchis deprecated and will be removed in 6.0.
tornado.httpclient.HTTPErrorhas been renamed to
HTTPClientErrorto avoid ambiguity in code that also has to deal with
tornado.web.HTTPError. The old name remains as an alias.
tornado.curl_httpclientnow supports non-ASCII characters in username and password arguments.
.HTTPResponse.request_timenow behaves consistently across
curl_httpclient, excluding time spent in the
max_clientsqueue in both cases (previously this time was included in
simple_httpclientbut excluded in
curl_httpclient). In both cases the time is now computed using a monotonic clock where available.
HTTPResponsenow has a
start_timeattribute recording a wall-clock (
time.time) timestamp at which the request started (after leaving the
max_clientsqueue if applicable).
parse_multipart_form_datanow recognizes non-ASCII filenames in RFC 2231/5987 (
HTTPServerRequest.writeis deprecated and will be removed in 6.0. Use the methods of
Malformed HTTP headers are now logged less noisily.
PeriodicCallbacknow supports a
jitterargument to randomly vary the timeout.
IOLoop.handle_callback_exceptionare deprecated and will be removed in 6.0.
IOLoopobjects are being opened and closed in multiple threads.
callbackarguments in this module are deprecated except for
BaseIOStream.set_close_callback. They will be removed in 6.0.
BaseIOStream.read_until_closeare deprecated and will be removed in 6.0.
Improved compatibility with GNU Hurd.
tornado.options.parse_config_filenow allows setting options to strings (which will be parsed the same way as
tornado.options.parse_command_line) in addition to the specified type for the option.
TwistedIOLoopare deprecated and will be removed in 6.0. Instead, Tornado will always use the asyncio event loop and twisted can be configured to do so as well.
tornado.stack_contextmodule is deprecated and will be removed in 6.0.
AsyncHTTPTestCase.fetchnow takes a
raise_errorargument. This argument has the same semantics as
AsyncHTTPClient.fetch, but defaults to false because tests often need to deal with non-200 responses (and for backwards-compatibility).
AsyncTestCase.waitmethods are deprecated.
RequestHandler.detachcan be used from methods that are not decorated with
@asynchronous(the decorator was required to use
Futuresthat can be used to wait for the last part of the response to be sent to the client.
on_finishfor the benefit of subclasses that may have overridden it.
asynchronousdecorator is deprecated and will be removed in 6.0.
RequestHandler.flushis deprecated and will be removed in 6.0.
When compression is enabled, memory limits now apply to the post-decompression size of the data, protecting against DoS attacks.
websocket_connectnow supports subprotocols.
selected_subprotocolattributes to see the subprotocol in use.
WebSocketHandler.select_subprotocolmethod is now called with an empty list instead of a list containing an empty string if no subprotocols were requested by the client.
WebSocketHandler.openmay now be a coroutine.
WebSocketHandler.pingis now optional.
Client-side websocket connections no longer buffer more than one message in memory at a time.
Exception logging now uses
WSGIAdapterare deprecated and will be removed in Tornado 6.0.