tornado       

##tornado框架分析

异步IO,有ASIO与IOCP的感觉

创建一个线程处理新的连接

创建一个进程处理新的连接

使用非阻塞的socket和epoll io模型

HTTPServer.listen tcpserver.listen _handle_connection handle_stream

IOLoop

io_loop.add_handler io_loop.start

ioloop.IOLoop.instance() IOLoop._instance 单例模式

工厂模式

def configurable_default(cls):
    if hasattr(select, "epoll"):
        from tornado.platform.epoll import EPollIOLoop
        return EPollIOLoop
    if hasattr(select, "kqueue"):
        # Python 2.6+ on BSD or Mac
        from tornado.platform.kqueue import KQueueIOLoop
        return KQueueIOLoop
    from tornado.platform.select import SelectIOLoop
    return SelectIOLoop





event_pairs = self._impl.poll(poll_timeout)

epoll模式
impl=select.epoll()

A non-blocking, single-threaded HTTP server

##reference

http://www.cnblogs.com/Bozh/archive/2012/07/19/2598696.html