Like `imap()` method but ordering of results is arbitrary.
(self, func, iterable, chunksize=1)
| 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): |