當前位置: 首頁>>代碼示例>>Python>>正文


Python TwistedIOLoop.add_callback方法代碼示例

本文整理匯總了Python中tornado.platform.twisted.TwistedIOLoop.add_callback方法的典型用法代碼示例。如果您正苦於以下問題:Python TwistedIOLoop.add_callback方法的具體用法?Python TwistedIOLoop.add_callback怎麽用?Python TwistedIOLoop.add_callback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.platform.twisted.TwistedIOLoop的用法示例。


在下文中一共展示了TwistedIOLoop.add_callback方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def __init__(self, io_loop=None):
        if not io_loop:
            io_loop = tornado.ioloop.IOLoop.current()
        self._io_loop = io_loop
        self._readers = {}  # map of reader objects to fd
        self._writers = {}  # map of writer objects to fd
        self._fds = {}  # a map of fd to a (reader, writer) tuple
        self._delayedCalls = {}
        PosixReactorBase.__init__(self)
        self.addSystemEventTrigger('during', 'shutdown', self.crash)

        # IOLoop.start() bypasses some of the reactor initialization.
        # Fire off the necessary events if they weren't already triggered
        # by reactor.run().
        def start_if_necessary():
            if not self._started:
                self.fireSystemEvent('startup')
        self._io_loop.add_callback(start_if_necessary)

    # IReactorTime 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:22,代碼來源:twisted.py

示例2: callFromThread

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def callFromThread(self, f, *args, **kw):
        assert callable(f), "%s is not callable" % f
        with NullContext():
            # This NullContext is mainly for an edge case when running
            # TwistedIOLoop on top of a TornadoReactor.
            # TwistedIOLoop.add_callback uses reactor.callFromThread and
            # should not pick up additional StackContexts along the way.
            self._io_loop.add_callback(f, *args, **kw)

    # We don't need the waker code from the super class, Tornado uses
    # its own waker. 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:13,代碼來源:twisted.py

示例3: stop

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def stop(self):
        PosixReactorBase.stop(self)
        fire_shutdown = functools.partial(self.fireSystemEvent, "shutdown")
        self._io_loop.add_callback(fire_shutdown) 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:6,代碼來源:twisted.py

示例4: add_callback

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def add_callback(self, callback, *args, **kwargs):
        self.reactor.callFromThread(
            self._run_callback,
            functools.partial(wrap(callback), *args, **kwargs)) 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:6,代碼來源:twisted.py

示例5: add_callback_from_signal

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def add_callback_from_signal(self, callback, *args, **kwargs):
        self.add_callback(callback, *args, **kwargs) 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:4,代碼來源:twisted.py

示例6: callFromThread

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def callFromThread(self, f, *args, **kw):
        """See `twisted.internet.interfaces.IReactorThreads.callFromThread`"""
        assert callable(f), "%s is not callable" % f
        with NullContext():
            # This NullContext is mainly for an edge case when running
            # TwistedIOLoop on top of a TornadoReactor.
            # TwistedIOLoop.add_callback uses reactor.callFromThread and
            # should not pick up additional StackContexts along the way.
            self._io_loop.add_callback(f, *args, **kw)

    # We don't need the waker code from the super class, Tornado uses
    # its own waker. 
開發者ID:hhstore,項目名稱:annotated-py-tornado,代碼行數:14,代碼來源:twisted.py

示例7: add_callback

# 需要導入模塊: from tornado.platform.twisted import TwistedIOLoop [as 別名]
# 或者: from tornado.platform.twisted.TwistedIOLoop import add_callback [as 別名]
def add_callback(self, callback, *args, **kwargs):
        self.reactor.callFromThread(self._run_callback,
                                    wrap(callback), *args, **kwargs) 
開發者ID:hhstore,項目名稱:annotated-py-tornado,代碼行數:5,代碼來源:twisted.py


注:本文中的tornado.platform.twisted.TwistedIOLoop.add_callback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。