def lazy_imap(data_processor, data_generator, n_cpus=1, stepsize=None):
    if not n_cpus:
        n_cpus = mp.cpu_count()
    elif n_cpus < 0:
        n_cpus = mp.cpu_count() - n_cpus
    if stepsize is None:
        stepsize = n_cpus
    with mp.Pool(processes=n_cpus) as p:
        while True:
            r = p.map(data_processor, islice(data_generator, stepsize))
            if r:
                yield r
            else:
                break