本文整理汇总了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)