HOW DO WE CALL TORNADO? what does it use?
i've also asked the question on stackoverflow:
http://stackoverflow.com/questions/8427830/what-is-exactly-tornado
Sent from my iPhone
2011/12/8, Didip Kerabat <did...@gmail.com>:
09.12.2011 01:14, aliane abdelouahab пишет:
--
С уважением,
Андрей Григорьев
2011/12/9, David Birdsong <david.b...@gmail.com>:
2011/12/9, Sergey Koval <serge...@gmail.com>:
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()2011/12/9, Gavin M. Roy <g...@myyearbook.com>:
> When writing Tornado applications, you are writing a HTTP server (like
> Apache, Nginx, Cherokee, Lighttpd) with application logic, say on port 8080
> instead of port 80.
>
> To serve it, it is recommended that you put a HTTP server like Apache,
> Nginx, Cherokee, Lighttpd in front of it acting as a reverse proxy to
> filter out malformed or otherwise bad requests so that the Tornado
> application does not see said requests. This approach also allows you to
> load balance multiple instances of a Tornado application running on
> different ports.
>
> It is not a WSGI (this is a protocol that is used between web servers and
> applications) nor a CGI (likewise a protocol used between webservers and
> applications), it is a HTTP server.
>
> You should do the base hello world example from
> http://www.tornadoweb.org/it should clear things up considerably.
Tornado doesn't serve "Python files", at least not in the sense that
something like CGI does. Tornado is an application framework. You use
it to write an application, and then it serves data generated by that
application via HTTP. It won't just run random .py/.cgi files from a
directory. It runs Python *functions* that you embed in the Tornado
framework.
The "Tornado way" is HTTP. It uses the same protocol as say, Apache
does. You are looking for something that simply isn't there.
Cliff
2011/12/9, Cliff Wells <cl...@develix.com>:
iostream protocol. there you go.
2011/12/9, David Birdsong <david.b...@gmail.com>:
Here is the protocol Tornado uses to "run a python file", and complete
reference to it:
http://docs.python.org/release/2.6.7/reference/simple_stmts.html#the-import-statement
As far as CherryPy goes, it is exactly the same as Tornado in this
regard. You are badly confusing how CherryPy and Tornado *execute* code
with how they present it to the client (which is often another HTTP
server/proxy). Because they are designed to be able to be run behind an
HTTP server (such as Apache or Nginx), they need a protocol to speak to
that server. In the case of Tornado, that protocol is HTTP. In the
case of CherryPy, it's also usually HTTP, but you can choose WSGI
instead.
Cliff
2011/12/9, Cliff Wells <cl...@develix.com>:
Generally it's a process per request. This is why those types of
solutions don't scale well. One must choose between allowing unbounded
concurrent connections and processes (and have unbounded RAM to allow
it), having a pool of handlers and let requests wait for one to become
free, or simply dropping requests when there aren't any available
handlers.
I suspect that most people use the pool of handlers model, since that
would seem to be the most robust.
Cliff
2011/12/10, Cliff Wells <cl...@develix.com>:
The difference is that it's a long-running process per request vs
starting a new Python interpreter for every request.
Cliff
Yes. FastCGI is more efficient than CGI since the interpreter doesn't
need to be loaded fresh for every request. Still, FastCGI applications
tend to utilize process-based concurrency models so scalability tends to
be limited (it's possible to write async apps using FCGI, but for some
reason it isn't popular, probably because HTTP is simpler).
WSGI was supposed to develop an async interface, but last I heard (a few
years ago), the idea was ditched due to requiring backwards-incompatible
changes to the API.
Cliff