tornado.ioloop.IOLoop.instance().start()中執行個體詳解

來源:互聯網
上載者:User

標籤:tornado.ioloop.ioloop.instance().start()調用了那個start()

我們來分析一下tornado.ioloop.IOLoop.instance().start(),學習了tornado後,當啟動服務的時候,我一直有一個疑惑,我們看一下源碼,IOLoop類中instance()是一個單例模式返回IOLoop執行個體函數

    @staticmethod    def instance():        """Returns a global `IOLoop` instance.        Most applications have a single, global `IOLoop` running on the        main thread.  Use this method to get this instance from        another thread.  To get the current thread‘s `IOLoop`, use `current()`.        """        if not hasattr(IOLoop, "_instance"):            with IOLoop._instance_lock:                if not hasattr(IOLoop, "_instance"):                    # New instance after double check                    IOLoop._instance = IOLoop()        return IOLoop._instance
然後我們再看一下IOloop類的start()函數
    def start(self):        """Starts the I/O loop.        The loop will run until one of the callbacks calls `stop()`, which        will make the loop stop after the current event iteration completes.        """               raise NotImplementedError()


本文出自 “lpj24” 部落格,請務必保留此出處http://6167018.blog.51cto.com/6157018/1532899

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.