human
I wrote the below code

    daemon_config['pytest_port'] = daemon_config['runtests_conn_check_port']
    request = None
    if fail_hard:
        fail_method = RuntimeError
    else:
        fail_method = RuntimeWarning
    log.info('[%s]    Starting    pytest    %s(%s)', daemon_name, daemon_log_prefix, daemon_id)
    attempts = 0
    process = None
    while (attempts <= 3):
        attempts += 1
        process = daemon_class(request, daemon_config, daemon_config_dir, bin_dir_path, daemon_log_prefix, cli_script_name=daemon_cli_script_name, slow_stop=slow_stop, environ=environ, cwd=cwd)
        process.start()
        if process.is_alive():
            try:
                connectable = process.wait_until_running(timeout=start_timeout)
                if (connectable is False):
                    connectable = process.wait_until_running(timeout=(start_timeout / 2))
                    if (connectable is False):
                        process.terminate()
                        if (attempts >= 3):
                            fail_method('The    pytest    {0}({1})    has    failed    to    confirm    running    status    after    {2}    attempts'.format(daemon_name, daemon_id, attempts))
                        continue
            except Exception as exc:
                log.exception('[%s]    %s', daemon_log_prefix, exc, exc_info=True)
                terminate_process(process.pid, kill_children=True, slow_stop=slow_stop)
                if (attempts >= 3):
                    raise fail_method(str(exc))
                continue
            log.info('[%s]    The    pytest    %s(%s)    is    running    and    accepting    commands    after    %d    attempts', daemon_log_prefix, daemon_name, daemon_id, attempts)
            def stop_daemon():
                log.info('[%s]    Stopping    pytest    %s(%s)', daemon_log_prefix, daemon_name, daemon_id)
                terminate_process(process.pid, kill_children=True, slow_stop=slow_stop)
                log.info('[%s]    pytest    %s(%s)    stopped', daemon_log_prefix, daemon_name,...

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

def start_daemon(daemon_name=None, daemon_id=None, daemon_log_prefix=None, daemon_cli_script_name=None, daemon_config=None, daemon_config_dir=None, daemon_class=None, bin_dir_path=None, fail_hard=False, start_timeout=10, slow_stop=False, environ=None, cwd=None):