human
Complete this python program:
def _queue_management_worker(executor_reference, processes, pending_work_items, work_ids_queue, call_queue, result_queue):
assistant
#Here is the Python code you requested.

    """Manages the communication between this process and the worker processes.
    This function is run in a local thread.
    Args:
    executor_reference: A weakref.ref to the ProcessPoolExecutor that owns
    this thread. Used to determine if the ProcessPoolExecutor has been
    garbage collected and that this function can exit.
    process: A list of the multiprocessing.Process instances used as
    workers.
    pending_work_items: A dict mapping work ids to _WorkItems e.g.
    {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
    work_ids_queue: A queue.Queue of work ids e.g. Queue([5, 6, ...]).
    call_queue: A multiprocessing.Queue that will be filled with _CallItems
    derived from _WorkItems for processing by the process workers.
    result_queue: A multiprocessing.Queue of _ResultItems generated by the
    process workers.
    """
    nb_shutdown_processes = [0]
    def shutdown_one_process():
        'Tell    a    worker    to    terminate,    which    will    in    turn    wake    us    again'
        call_queue.put(None)
        nb_shutdown_processes[0] += 1
    while True:
        _add_call_item_to_queue(pending_work_items, work_ids_queue, call_queue)
        result_item = result_queue.get(block=True)
        if (result_item is not None):
            work_item = pending_work_items[result_item.work_id]
            del pending_work_items[result_item.work_id]
            if result_item.exception:
                work_item.future.set_exception(result_item.exception)
            else:
                work_item.future.set_result(result_item.result)
        executor = executor_reference()
        if (_shutdown or (executor is None) or executor._shutdown_thread):
            if (not pending_work_items):
                while (nb_shutdown_processes[0] < len(processes)):
                    shutdown_one_process()
                for p in processes:
                    p.join()
                call_queue.close()
                return
        del executor