本文整理汇总了Python中pool.Pool.imap_unordered方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.imap_unordered方法的具体用法?Python Pool.imap_unordered怎么用?Python Pool.imap_unordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pool.Pool
的用法示例。
在下文中一共展示了Pool.imap_unordered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAdd
# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import imap_unordered [as 别名]
def testAdd(self):
results = set()
pool = Pool(3)
for result in pool.imap_unordered(Run, [[x] for x in range(0, 10)]):
results.add(result.value)
if result.value < 30:
pool.add([result.value + 20])
self.assertEquals(set(range(0, 10) + range(20, 30) + range(40, 50)),
results)
示例2: testException
# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import imap_unordered [as 别名]
def testException(self):
results = set()
pool = Pool(3)
for result in pool.imap_unordered(Run, [[x] for x in range(0, 12)]):
# Item 10 will not appear in results due to an internal exception.
results.add(result.value)
expect = set(range(0, 12))
expect.remove(10)
self.assertEquals(expect, results)
示例3: testNormal
# 需要导入模块: from pool import Pool [as 别名]
# 或者: from pool.Pool import imap_unordered [as 别名]
def testNormal(self):
results = set()
pool = Pool(3)
for result in pool.imap_unordered(Run, [[x] for x in range(0, 10)]):
results.add(result.value)
self.assertEquals(set(range(0, 10)), results)