An equivalent of itertools.imap(). The chunksize argument is the same as the one used by the map() method. For very long iterables using a large value for chunksize can make make the job complete much faster than using the default value of 1. Also i
(self, func, iterable, chunksize=1)
| 127 | return self.map_async(func, iterable, chunksize).get() |
| 128 | |
| 129 | def imap(self, func, iterable, chunksize=1): |
| 130 | """ |
| 131 | An equivalent of itertools.imap(). |
| 132 | |
| 133 | The chunksize argument is the same as the one used by the |
| 134 | map() method. For very long iterables using a large value for |
| 135 | chunksize can make make the job complete much faster than |
| 136 | using the default value of 1. |
| 137 | |
| 138 | Also if chunksize is 1 then the next() method of the iterator |
| 139 | returned by the imap() method has an optional timeout |
| 140 | parameter: next(timeout) will raise processing.TimeoutError if |
| 141 | the result cannot be returned within timeout seconds. |
| 142 | """ |
| 143 | collector = OrderedResultCollector(as_iterator=True) |
| 144 | self._create_sequences(func, iterable, chunksize, collector) |
| 145 | return iter(collector) |
| 146 | |
| 147 | def imap_unordered(self, func, iterable, chunksize=1): |
| 148 | """The same as imap() except that the ordering of the results |
no test coverage detected