human
I wrote the below code

    def wait_until_true(fn):
        '\n                                Sleeps    until    fn    is    true\n                                '
        while (not fn()):
            time.sleep(0.1)
    def get_num_workers_running(gunicorn_master_proc):
        workers = psutil.Process(gunicorn_master_proc.pid).children()
        return len(workers)
    def get_num_ready_workers_running(gunicorn_master_proc):
        workers = psutil.Process(gunicorn_master_proc.pid).children()
        ready_workers = [proc for proc in workers if (settings.GUNICORN_WORKER_READY_PREFIX in proc.cmdline()[0])]
        return len(ready_workers)
    def start_refresh(gunicorn_master_proc):
        batch_size = conf.getint('webserver', 'worker_refresh_batch_size')
        logging.debug('%s    doing    a    refresh    of    %s    workers', state, batch_size)
        sys.stdout.flush()
        sys.stderr.flush()
        excess = 0
        for _ in range(batch_size):
            gunicorn_master_proc.send_signal(signal.SIGTTIN)
            excess += 1
            wait_until_true((lambda : ((num_workers_expected + excess) == get_num_workers_running(gunicorn_master_proc))))
    wait_until_true((lambda : (num_workers_expected == get_num_workers_running(gunicorn_master_proc))))
    while True:
        num_workers_running = get_num_workers_running(gunicorn_master_proc)
        num_ready_workers_running = get_num_ready_workers_running(gunicorn_master_proc)
        state = '[{0}    /    {1}]'.format(num_ready_workers_running, num_workers_running)
        if (num_ready_workers_running < num_workers_running):
            logging.debug('%s    some    workers    are    starting    up,    waiting...', state)
            sys.stdout.flush()
            time.sleep(1)
        elif (num_workers_running > num_workers_expected):
            excess = (num_workers_running - num_workers_expected)
            logging.debug('%s    killing    %s    workers', state, excess)
            for _ in range(excess):
               ...

What's a good function header?
assistant
#Here's a good function header.

def restart_workers(gunicorn_master_proc, num_workers_expected):