MCPcopy Index your code
hub / github.com/python/cpython / imap_unordered

Method imap_unordered

Lib/multiprocessing/pool.py:425–451  ·  view source on GitHub ↗

Like `imap()` method but ordering of results is arbitrary.

(self, func, iterable, chunksize=1)

Source from the content-addressed store, hash-verified

423 return (item for chunk in result for item in chunk)
424
425 def imap_unordered(self, func, iterable, chunksize=1):
426 '''
427 Like `imap()` method but ordering of results is arbitrary.
428 '''
429 self._check_running()
430 if chunksize == 1:
431 result = IMapUnorderedIterator(self)
432 self._taskqueue.put(
433 (
434 self._guarded_task_generation(result._job, func, iterable),
435 result._set_length
436 ))
437 return result
438 else:
439 if chunksize < 1:
440 raise ValueError(
441 "Chunksize must be 1+, not {0!r}".format(chunksize))
442 task_batches = Pool._get_tasks(func, iterable, chunksize)
443 result = IMapUnorderedIterator(self)
444 self._taskqueue.put(
445 (
446 self._guarded_task_generation(result._job,
447 mapstar,
448 task_batches),
449 result._set_length
450 ))
451 return (item for chunk in result for item in chunk)
452
453 def apply_async(self, func, args=(), kwds={}, callback=None,
454 error_callback=None):

Callers 4

test_empty_iterableMethod · 0.95
testFunction · 0.80
test_imap_unorderedMethod · 0.80

Calls 6

_check_runningMethod · 0.95
_get_tasksMethod · 0.80
putMethod · 0.45
formatMethod · 0.45