Questions tagged [tornado]

Tornado is a scalable web server and web framework for Python specializing in handling thousands of simultaneous connections and real-time services.

Tornado

A web server and a web framework for Python. Originally built to power FriendFeed (owned by Facebook), it is now an open source project and used by sites like Quora and Hipmunk. Tornado uses non-blocking IO and asynchronous programming patterns to attain greater scalability and speed. While documentation is somewhat light, there is an active mailing list and a supportive community. The framework is also designed to be simple, along the lines of web.py or bottle, without some of the more complex setup of web frameworks like Django.

The current version is 5.0.2

Hello, world

Here is a simple “Hello, world” example web app for Tornado:

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])    

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

This example does not use any of Tornado’s asynchronous features; for that see this simple chat room.

3769 questions
184
votes
4 answers

When to use Tornado, when to use Twisted / Cyclone / GEvent / other

Which of these frameworks / libraries would be the best choise for building modern multiuser web application? I would love to have an asynchronous webserver which will allow me to scale easly. What solution will give the best performance /…
Wojciech Danilo
  • 11,573
  • 17
  • 66
  • 132
166
votes
1 answer

Is JSON Hijacking still an issue in modern browsers?

I am using Backbone.js and the Tornado web server. The standard behavior for receiving collection data in Backbone is to send as a JSON Array. On the other hand, Tornado's standard behavior is to not allow JSON Array's due to the following…
Rocketman
  • 3,464
  • 5
  • 27
  • 30
107
votes
9 answers

How can I periodically execute a function with asyncio?

I'm migrating from tornado to asyncio, and I can't find the asyncio equivalent of tornado's PeriodicCallback. (A PeriodicCallback takes two arguments: the function to run and the number of milliseconds between calls.) Is there such an equivalent in…
2Cubed
  • 3,401
  • 7
  • 23
  • 40
88
votes
2 answers

When and how to use Tornado? When is it useless?

Ok, Tornado is non-blocking and quite fast and it can handle a lot of standing requests easily. But I guess it's not a silver bullet and if we just blindly run Django-based or any other site with Tornado it won't give any performance boost. I…
Vladimir Sidorenko
  • 4,265
  • 3
  • 19
  • 13
81
votes
5 answers

Differences between node.js and Tornado

Besides the fact that node.js is written in JS and Tornado in Python, what are some of the differences between the two? They're both non-blocking asynchronous web servers, right? Why choose one over the other besides the language?
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
78
votes
4 answers

Jupyter Notebook with Python 3.8 - NotImplementedError

Upgraded recently to Python 3.8, and installed jupyter. However, when trying to run jupyter notebook getting the following error: File "c:\users\user\appdata\local\programs\python\python38\lib\site-packages\tornado\platform\asyncio.py", line 99,…
drec4s
  • 7,946
  • 8
  • 33
  • 54
60
votes
6 answers

How to make SQLAlchemy in Tornado to be async?

How to make SQLAlchemy in Tornado to be async ? I found example for MongoDB on async mongo example but I couldn't find anything like motor for SQLAlchemy. Does anyone know how to make SQLAlchemy queries to execute with tornado.gen ( I am using MySQL…
Damir
  • 54,277
  • 94
  • 246
  • 365
58
votes
2 answers

Is Tornado a replacement to Django or are they complementary to each other?

I have several questions about Tornado and other web frameworks. 1) Tornado claims to be a webserver (a non-blocking one, therefore much performant), so some people said it does not play the role of django --i.e., they say tornado is not a web…
chen
  • 4,302
  • 6
  • 41
  • 70
57
votes
2 answers

using Flask and Tornado together?

I am a big fan of Flask - in part because it is simple and in part because has a lot of extensions. However, Flask is meant to be used in a WSGI environment, and WSGI is not a non-blocking, so (I believe) it doesn't scale as well as Tornado for…
Abdelouahab
  • 7,331
  • 11
  • 52
  • 82
49
votes
3 answers

tornado 403 GET warning when opening websocket

I found this python script which should allow me to open a WebSocket. However, I receive the warning [W 1402720 14:44:35 web:1811] 403 GET / (192.168.0.102) 11.02 ms in my Linux terminal when trying to open the actual WebSocket (using Old WebSocket…
Dorus
  • 493
  • 1
  • 4
  • 6
49
votes
5 answers

How to get image size (bytes) using PIL

I found out how to use PIL to get the image dimensions, but not the file size in bytes. I need to know the file size to decide if the file is too big to be uploaded to the database.
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65
48
votes
3 answers

How to best perform Multiprocessing within requests with the python Tornado server?

I am using the I/O non-blocking python server Tornado. I have a class of GET requests which may take a significant amount of time to complete (think in the range of 5-10 seconds). The problem is that Tornado blocks on these requests so that…
Rocketman
  • 3,464
  • 5
  • 27
  • 30
45
votes
4 answers

Tornado URL query parameters

I've been playing around with Tornado, and I've written some code that doesn't seem very nice. I'm writing an app to store recipes as an example. These are my handlers: handlers = [ (r"/recipes/", RecipeHandler), (r"/recipes",…
colinjwebb
  • 4,362
  • 7
  • 31
  • 35
43
votes
4 answers

Why use Tornado and Flask together?

As far as I can tell Tornado is a server and a framework in one. It seems to me that using Flask and Tornado together is like adding another abstraction layer (more overhead). Why do people use Flask and Tornado together, what are the advantages?
3k-
  • 2,467
  • 2
  • 23
  • 24
37
votes
9 answers

How do I stop Tornado web server?

I've been playing around a bit with the Tornado web server and have come to a point where I want to stop the web server (for example during unit testing). The following simple example exists on the Tornado web page: import tornado.ioloop import…
Adam Lindberg
  • 16,447
  • 6
  • 65
  • 85
1
2 3
99 100