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


Python ThreadPool.dispatch方法代码示例

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


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

示例1: ThreadedRunner

# 需要导入模块: from twisted.python.threadpool import ThreadPool [as 别名]
# 或者: from twisted.python.threadpool.ThreadPool import dispatch [as 别名]
class ThreadedRunner(SimpleRunner):
    """Run tests using a threadpool.
    Uses TwistedPython's thread pool"""
    def __init__(self, result_class):
        from twisted.python.threadpool import ThreadPool

        SimpleRunner.__init__(self, _threadclass(result_class))
        
        self._pool = ThreadPool()
        self._pool.start()

    def run(self, fixture):
        assert not self._done
        self._pool.dispatch(None, fixture, self._result)

    def result(self):
        self._pool.stop()
        return SimpleRunner.result(self)
开发者ID:bhramoss,项目名称:code,代码行数:20,代码来源:recipe-391414.py


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