def worker(func, sigint_handler, input, output):
    """ Generic worker: call <func> for each item pulled from
        the <input> queue until a None gets pulled.

        For each result obtained from calling <func>, push the
        result into <output> queue.

        After receiving a None, close the <output> queue.
        """
    for item in iter(input.get, None):
        output.put(func(item, sigint_handler))
    output.close()
    output.join_thread()
