当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.IReactorThreads方法代码示例

本文整理汇总了Python中twisted.internet.interfaces.IReactorThreads方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IReactorThreads方法的具体用法?Python interfaces.IReactorThreads怎么用?Python interfaces.IReactorThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.interfaces的用法示例。


在下文中一共展示了interfaces.IReactorThreads方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_lotsOfThreadsAreScheduledCorrectly

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def test_lotsOfThreadsAreScheduledCorrectly(self):
        """
        L{IReactorThreads.callFromThread} can be used to schedule a large
        number of calls in the reactor thread.
        """
        def addAndMaybeFinish():
            self.counter += 1
            if self.counter == 100:
                self.deferred.callback(True)

        for i in range(100):
            self.schedule(addAndMaybeFinish)

        return self.deferred 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:test_internet.py

示例2: callFromThread

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def callFromThread(self, f, *args, **kw):
            """
            See L{twisted.internet.interfaces.IReactorThreads.callFromThread}.
            """
            assert callable(f), "%s is not callable" % (f,)
            # lists are thread-safe in CPython, but not in Jython
            # this is probably a bug in Jython, but until fixed this code
            # won't work in Jython.
            self.threadCallQueue.append((f, args, kw))
            self.wakeUp() 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:base.py

示例3: getThreadPool

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def getThreadPool(self):
            """
            See L{twisted.internet.interfaces.IReactorThreads.getThreadPool}.
            """
            if self.threadpool is None:
                self._initThreadPool()
            return self.threadpool 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:base.py

示例4: callInThread

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def callInThread(self, _callable, *args, **kwargs):
            """
            See L{twisted.internet.interfaces.IReactorThreads.callInThread}.
            """
            self.getThreadPool().callInThread(_callable, *args, **kwargs) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:base.py

示例5: suggestThreadPoolSize

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def suggestThreadPoolSize(self, size):
            """
            See L{twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize}.
            """
            self.getThreadPool().adjustPoolsize(maxthreads=size) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:base.py

示例6: test_lotsOfThreadsAreScheduledCorrectly

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def test_lotsOfThreadsAreScheduledCorrectly(self):
        """
        L{IReactorThreads.callFromThread} can be used to schedule a large
        number of calls in the reactor thread.
        """
        def addAndMaybeFinish():
            self.counter += 1
            if self.counter == 100:
                self.deferred.callback(True)

        for i in xrange(100):
            self.schedule(addAndMaybeFinish)

        return self.deferred 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:16,代码来源:test_internet.py

示例7: callFromThread

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def callFromThread(self, f, *args, **kw):
            """See twisted.internet.interfaces.IReactorThreads.callFromThread.
            """
            assert callable(f), "%s is not callable" % (f,)
            # lists are thread-safe in CPython, but not in Jython
            # this is probably a bug in Jython, but until fixed this code
            # won't work in Jython.
            self.threadCallQueue.append((f, args, kw))
            self.wakeUp() 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:11,代码来源:base.py

示例8: callInThread

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def callInThread(self, _callable, *args, **kwargs):
            """See twisted.internet.interfaces.IReactorThreads.callInThread.
            """
            if self.threadpool is None:
                self._initThreadPool()
            self.threadpool.callInThread(_callable, *args, **kwargs) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:8,代码来源:base.py

示例9: suggestThreadPoolSize

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def suggestThreadPoolSize(self, size):
            """See twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize.
            """
            if size == 0 and not self.threadpool:
                return
            if not self.threadpool:
                self._initThreadPool()
            self.threadpool.adjustPoolsize(maxthreads=size) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:10,代码来源:base.py

示例10: _bail

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def _bail(self):
        from twisted.internet import reactor
        d = defer.Deferred()
        reactor.addSystemEventTrigger('after', 'shutdown',
                                      lambda: d.callback(None))
        reactor.fireSystemEvent('shutdown') # radix's suggestion
        treactor = interfaces.IReactorThreads(reactor, None)
        if treactor is not None:
            treactor.suggestThreadPoolSize(0)
        # As long as TestCase does crap stuff with the reactor we need to 
        # manually shutdown the reactor here, and that requires util.wait
        # :(
        # so that the shutdown event completes
        unittest.TestCase('mktemp')._wait(d) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:16,代码来源:runner.py

示例11: __init__

# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorThreads [as 别名]
def __init__(self, ifname: str, clock: IReactorThreads = None):
        if clock is None:
            clock = reactor
        self.clock = clock  # type: IReactorThreads
        self.ifname = ifname  # type: str
        self.servers = None  # type: set
        self.dhcpRequestsDeferredList = None  # type: DeferredList
        self.deferredDHCPRequests = []  # type: List[Deferred]
        self.transaction_id = make_dhcp_transaction_id()  # type: bytes 
开发者ID:maas,项目名称:maas,代码行数:11,代码来源:detect.py


注:本文中的twisted.internet.interfaces.IReactorThreads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。