What’s new in Tornado 6.3.0¶
Apr 17, 2023¶
Highlights¶
The new
Applicationsettingxsrf_cookie_namecan now be used to take advantage of the__Hostcookie prefix for improved security. To use it, add{"xsrf_cookie_name": "__Host-xsrf", "xsrf_cookie_kwargs": {"secure": True}}to yourApplicationsettings. Note that this feature currently only works when HTTPS is used.WSGIContainernow supports running the application in aThreadPoolExecutorso the event loop is no longer blocked.AsyncTestCaseandAsyncHTTPTestCase, which were deprecated in Tornado 6.2, are no longer deprecated.WebSockets are now much faster at receiving large messages split into many fragments.
General changes¶
Python 3.7 is no longer supported; the minimum supported Python version is 3.8. Python 3.12 is now supported.
To avoid spurious deprecation warnings, users of Python 3.10 should upgrade to at least version 3.10.9, and users of Python 3.11 should upgrade to at least version 3.11.1.
Tornado submodules are now imported automatically on demand. This means it is now possible to use a single
import tornadostatement and refer to objects in submodules such astornado.web.RequestHandler.
Deprecation notices¶
In Tornado 7.0,
tornado.testing.ExpectLogwill matchWARNINGand above regardless of the current logging configuration, unless thelevelargument is used.RequestHandler.get_secure_cookieis now a deprecated alias forRequestHandler.get_signed_cookie.RequestHandler.set_secure_cookieis now a deprecated alias forRequestHandler.set_signed_cookie.RequestHandler.clear_all_cookiesis deprecated. No direct replacement is provided;RequestHandler.clear_cookieshould be used on individual cookies.Calling the
IOLoopconstructor without amake_currentargument, which was deprecated in Tornado 6.2, is no longer deprecated.AsyncTestCaseandAsyncHTTPTestCase, which were deprecated in Tornado 6.2, are no longer deprecated.AsyncTestCase.get_new_ioloopis deprecated.
tornado.auth¶
New method
GoogleOAuth2Mixin.get_google_oauth_settingscan now be overridden to get credentials from a source other than theApplicationsettings.
tornado.gen¶
contextvarsnow work properly when a@gen.coroutinecalls a native coroutine.
tornado.options¶
parse_config_filenow recognizes single comma-separated strings (in addition to lists of strings) for options withmultiple=True.
tornado.web¶
New
Applicationsettingxsrf_cookie_namecan be used to change the name of the XSRF cookie. This is most useful to take advantage of the__Host-cookie prefix.RequestHandler.get_secure_cookieandRequestHandler.set_secure_cookie(and related methods and attributes) have been renamed toget_signed_cookieandset_signed_cookie. This makes it more explicit what kind of security is provided, and avoids confusion with theSecurecookie attribute and__Secure-cookie prefix. The old names remain supported as deprecated aliases.RequestHandler.clear_cookienow accepts all keyword arguments accepted byset_cookie. In some cases clearing a cookie requires certain arguments to be passed the same way in which it was set.RequestHandler.clear_all_cookiesnow accepts additional keyword arguments for the same reason asclear_cookie. However, since the requirements for additional arguments mean that it cannot reliably clear all cookies, this method is now deprecated.
tornado.websocket¶
It is now much faster (no longer quadratic) to receive large messages that have been split into many fragments.
websocket_connectnow accepts aresolverparameter.
tornado.wsgi¶
WSGIContainernow accepts anexecutorparameter which can be used to run the WSGI application on a thread pool.