Trade Off

supercalifragilisticexpialidocious

Tornado-1

This is the first part of Tornado studying project.

Tornado can be roughly divided into four major components:

  • A web framework (including RequestHandler which is subclassed to create web applications, and various supporting classes).
  • Client- and server-side implementions of HTTP (HTTPServer and AsyncHTTPClient).
  • An asynchronous networking library (IOLoop and IOStream), which serve as the building blocks for the HTTP components and can also be used to implement other protocols.
  • A coroutine library (tornado.gen) which allows asynchronous code to be written in a more straightforward way than chaining callbacks.

Tornado uses a signle-threaded event loop.This means that all application code should aim to be asynchronous and non-blocking because only one operation can be active at a time.

There are many styles of asynchronous interfaces:

  • Callback argument
  • Return a placeholder (Future, Promise, Deferred)
  • Deliver to a queue
  • Callback registry (e.g. POSIX signals)

There is no free way to make a synchronous function asynchronous in a way that is transparent to its callers.

Coroutines are the recommended way to write asynchronous code in Tornado

A function containing yield is a generator. All generators are asynchronous; when called they return a generator object instead of running to completion.

Comments