本文整理匯總了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)