Overview
Tornado 6.1, released on October 30, 2021, adds official Python 3.9 support and improves asyncio ecosystem compatibility.
Main Features
Python 3.9 support
Tornado 6.1 is fully compatible with Python 3.9, including new type syntax and integration with asyncio improvements.
python
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
async def get(self):
self.write({'message': 'Tornado 6.1 with Python 3.9'})
def make_app():
return tornado.web.Application([
(r'/', MainHandler),
])
# app = make_app()
# app.listen(8888)
# tornado.ioloop.IOLoop.current().start()
Asyncio compatibility
Asyncio integration is strengthened: the Tornado event loop now uses asyncio by default, making it easier to mix with other async libraries.
python
import asyncio
import tornado.web
from tornado.httpclient import AsyncHTTPClient
async def fetch_data():
"""Using Tornado's async HTTP client."""
client = AsyncHTTPClient()
response = await client.fetch('https://httpbin.org/get')
return response.body.decode()
# Compatible with asyncio.run()
# result = asyncio.run(fetch_data())
# print(result)
