Overview

Tornado 6.2, released on January 15, 2022, adds official Python 3.10 support and improves WebSocket connection handling.

Main Features

Python 3.10 support

Tornado 6.2 is compatible with Python 3.10 and takes advantage of asyncio improvements for better event loop performance.

python
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    async def get(self):
        self.write({'message': 'Hello from Tornado 6.2'})

app = tornado.web.Application([
    (r'/', MainHandler),
])
# app.listen(8888)
# tornado.ioloop.IOLoop.current().start()

Improved WebSocket

WebSocket handling is improved with better ping/pong control and per-message compression.

python
import tornado.websocket

class ChatHandler(tornado.websocket.WebSocketHandler):
    clients = set()

    def open(self):
        ChatHandler.clients.add(self)

    def on_message(self, message):
        for client in ChatHandler.clients:
            client.write_message(message)

    def on_close(self):
        ChatHandler.clients.discard(self)

Sources