What’s new in Tornado 6.2.0¶
Jul 3, 2022¶
Deprecation notice¶
Python 3.10 has begun the process of significant changes to the APIs for managing the event loop. Calls to methods such as
asyncio.get_event_loopmay now raiseDeprecationWarningif no event loop is running. This has significant impact on the patterns for initializing applications, and in particular invalidates patterns that have long been the norm in Tornado’s documentation and actual usage. In the future (with some as-yet-unspecified future version of Python), the old APIs will be removed. The new recommended pattern is to start the event loop withasyncio.run. More detailed migration guides will be coming in the future.The
IOLoopconstructor is deprecated unless themake_current=Falseargument is used. UseIOLoop.currentwhen the loop is already running instead.AsyncTestCase(andAsyncHTTPTestCase) are deprecated. Useunittest.IsolatedAsyncioTestCaseinstead.Multi-process
TCPServer.bind/TCPServer.startis deprecated. SeeTCPServerdocs for supported alternatives.AnyThreadEventLoopPolicyis deprecated. This class controls the creation of the “current” event loop so it will be removed when that concept is no longer supported.IOLoop.make_currentandIOLoop.clear_currentare deprecated. In the future the concept of a “current” event loop as distinct from one that is currently running will be removed.
TwistedResolverandCaresResolverare deprecated and will be removed in Tornado 7.0.
General changes¶
The minimum supported Python version is now 3.7.
Wheels are now published with the Python stable ABI (
abi3) for compatibility across versions of Python.SSL certificate verfication and hostname checks are now enabled by default in more places (primarily in client-side usage of
SSLIOStream).Various improvements to type hints throughout the package.
CI has moved from Travis and Appveyor to Github Actions.
tornado.gen¶
Fixed a bug in which
WaitIterator.current_indexcould be incorrect.tornado.gen.TimeoutErroris now an alias forasyncio.TimeoutError.
tornado.http1connection¶
max_body_sizemay now be set to zero to disallow a non-empty body.Content-Encoding: gzipis now recognized case-insensitively.
tornado.httpclient¶
curl_httpclientnow supports non-ASCII (ISO-8859-1) header values, same assimple_httpclient.
tornado.ioloop¶
PeriodicCallbacknow understands coroutines and will not start multiple copies if a previous invocation runs too long.PeriodicCallbacknow acceptsdatetime.timedeltaobjects in addition to numbers of milliseconds.Avoid logging “Event loop is closed” during shutdown-related race conditions.
Tornado no longer calls
logging.basicConfigwhen starting an IOLoop; this has been unnecessary since Python 3.2 added a logger of last resort.The
IOLoopconstructor now accepts anasyncio_loopkeyword argument to initialize with a specfied asyncio event loop.It is now possible to construct an
IOLoopon one thread (withmake_current=False) and start it on a different thread.
tornado.iostream¶
SSLIOStreamnow supports reading more than 2GB at a time.IOStream.writenow supports typedmemoryviewobjects.
tornado.locale¶
load_gettext_translationsno longer logs errors when language directories exist but do not contain the expected file.
tornado.netutil¶
is_valid_ipno longer raises exceptions when the input is too long.The default resolver now uses the same methods (and thread pool) as
asyncio.
tornado.tcpserver¶
TCPServer.listennow supports more arguments to pass through tonetutil.bind_sockets.
tornado.testing¶
bind_unused_portnow takes an optionaladdressargument.Wrapped test methods now include the
__wrapped__attribute.
tornado.web¶
When using a custom
StaticFileHandlersubclass, thereset()method is now called on this subclass instead of the base class.Improved handling of the
Accept-Languageheader.Application.listennow supports more arguments to pass through tonetutil.bind_sockets.
tornado.websocket¶
WebSocketClientConnection.write_messagenow acceptsdictarguments for consistency withWebSocketHandler.write_message.WebSocketClientConnection.write_messagenow raises an exception as documented if the connection is already closed.