当前位置: 首页>>代码示例>>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;未经允许,请勿转载。