'Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.'

def imap(self, func, iterable, chunksize=1):

    if (self._state != RUN):
        raise ValueError('Pool    not    running')
    if (chunksize == 1):
        result = IMapIterator(self._cache)
        self._taskqueue.put((((result._job, i, func, (x,), {}) for (i, x) in enumerate(iterable)), result._set_length))
        return result
    else:
        assert (chunksize > 1)
        task_batches = Pool._get_tasks(func, iterable, chunksize)
        result = IMapIterator(self._cache)
        self._taskqueue.put((((result._job, i, mapstar, (x,), {}) for (i, x) in enumerate(task_batches)), result._set_length))
        return (item for chunk in result for item in chunk)
