human
I wrote the below code

    logger = logging.getLogger(u'workflow')
    PIPE = subprocess.PIPE
    cmdline = runtime.cmdline
    if redirect_x:
        (exist_xvfb, _) = _exists_in_path(u'xvfb-run', runtime.environ)
        if (not exist_xvfb):
            raise RuntimeError(u'Xvfb    was    not    found,    X    redirection    aborted')
        cmdline = (u'xvfb-run    -a    ' + cmdline)
    env = _canonicalize_env(runtime.environ)
    default_encoding = locale.getdefaultlocale()[1]
    if (default_encoding is None):
        default_encoding = u'UTF-8'
    if (output == u'file'):
        errfile = os.path.join(runtime.cwd, u'stderr.nipype')
        outfile = os.path.join(runtime.cwd, u'stdout.nipype')
        stderr = open(errfile, u'wb')
        stdout = open(outfile, u'wb')
        proc = subprocess.Popen(cmdline, stdout=stdout, stderr=stderr, shell=True, cwd=runtime.cwd, env=env)
    else:
        proc = subprocess.Popen(cmdline, stdout=PIPE, stderr=PIPE, shell=True, cwd=runtime.cwd, env=env)
    result = {}
    errfile = os.path.join(runtime.cwd, u'stderr.nipype')
    outfile = os.path.join(runtime.cwd, u'stdout.nipype')
    mem_mb = 0
    num_threads = 1
    interval = 0.5
    if (output == u'stream'):
        streams = [Stream(u'stdout', proc.stdout), Stream(u'stderr', proc.stderr)]
        def _process(drain=0):
            try:
                res = select.select(streams, [], [], timeout)
            except select.error as e:
                iflogger.info(str(e))
                if (e[0] == errno.EINTR):
                    return
                else:
                    raise
            else:
                for stream in res[0]:
                    stream.read(drain)
        while (proc.returncode is None):
            if runtime_profile:
                (mem_mb, num_threads) = get_max_resources_used(proc.pid, mem_mb, num_threads)
            proc.poll()
            _process()
            time.sleep(interval)
        _process(drain=1)
        result = {}
        temp = []
        for stream in streams:
            rows...

What's a good function header?

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

def run_command(runtime, output=None, timeout=0.01, redirect_x=False):