Worker for muliprocessing.
    
    A worker repeatedly picks a dict of arguments in the queue and computes 
    f for this set of arguments, until the input queue is empty.

def worker(qin, qout, f):
    """Worker for muliprocessing.
    
    A worker repeatedly picks a dict of arguments in the queue and computes 
    f for this set of arguments, until the input queue is empty.
    """
    while not qin.empty():
        i, args = qin.get()
        qout.put((i, f(**args)))