I needed something that could do http get, http post and comet via html5 websockets.
I looked at the other options gevent, twisted, etc, I either had installation problems, or performance issues, or it was hard to figure it out how to it. With tornado this was trivial: ----- begin ------ LISTENERS = [] class NewMsgHandler(tornado.web.RequestHandler): def get(self): self.write('<html><body>Hello</body></html>') def post(self): data = self.request.arguments['data'][0] [element.write_message(data) for element in LISTENERS] class RealtimeHandler(tornado.websocket.WebSocketHandler): def open(self): LISTENERS.append(self) def on_message(self, message): pass def on_close(self): LISTENERS.remove(self) application = tornado.web.Application([ (r'/', NewMsgHandler), # for get and post (r'/websocket/', RealtimeHandler), # for websockets ], auto_reload=True) http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) tornado.ioloop.IOLoop.instance().start() ---- end ---- On post it streams data to all clients connected with websockets. It runs as fast as bare metal. It cannot possibly be faster. I tried with up with 100 posts/seconds with 10 connected clients) and 1 post/second with 500 connected clients (my my laptop which does not even support epoll). Web2py acts like a proxy for the post (does the form generation, validation, database IO, etc.) but stays out of the way as far as websockets are concerned. Web2py serves all the pages that need db access. The clients receive data from tornado and store (do not process it else slows down the server, it queues it). The processing.js thread processes the data 5times/second for a smooth interface. Massimo On Dec 28, 11:27 am, David Marko <dma...@tiscali.cz> wrote: > Why tornado as webserver? Any observations you can share? > > David