Search code examples
pythonroutestornadotcpserver

Python Tornado - TCPServer and Application


I set up a tornado.tcpserver.TCPServer which uses H2, to get HTTP2 working. Now i face following issue: I can't create routes and it looks like there's no way to bind Tornado.web with Tornado.tcpserver...

AFAIK tornado.web.Application works only with tornado.httpserver.HTTPServer :/ But Tornado still doesn't support HTTP2, so using tornado.httpserver is absolutely a no-go from me -_-

Does anyone know a workaround or function which allows us to bind tornado.web.Application with tornado.tcpserver.TCPServer?


Solution

  • tornado.web.Application implements the HTTPServerConnectionDelegate interface. To use it from another server, call start_request and pass the http headers and other data from your server implementation to the returned HTTPMessageDelegate.

    There's also a native tornado implementation of HTTP/2 in https://github.com/bdarnell/tornado_http2