def run_multiprocessing(target, jobs, n=1, nproc=None, **kwargs):
    def consumer(f, q_in, q_out):
        while True:
            val = q_in.get()
            if val is None:
                q_in.task_done()
                break
            i, x = val
            res = (i, f(*x))
            q_in.task_done()
            q_out.put(res)
    def mulpmap(f, X, nproc):
        nproc = nproc or multiprocessing.cpu_count()
        q_in = multiprocessing.JoinableQueue()
        q_out = multiprocessing.Queue()
        workers = [multiprocessing.Process(target=consumer, args=(f, q_in, q_out), daemon=True) for _ in range(nproc)]
        sent = [q_in.put((i, x)) for i, x in enumerate(X)]
        num_tasks = len(sent)
        [q_in.put(None) for _ in range(nproc)]
        [w.start() for w in workers]
        q_in.join()
        res = [q_out.get() for _ in range(num_tasks)]
        return [x for (_, x) in sorted(res)]
    res = mulpmap(
        target, ((job, i + 1, j + 1) for (i, job), j in itertools.product(enumerate(jobs), range(n))), nproc)
    return [res[i: i + n] for i in range(0, len(res), n)]