human
I wrote the below code

    def pump_stream(cmdline, name, stream, is_decode, handler):
        try:
            for line in stream:
                if handler:
                    if is_decode:
                        line = line.decode(defenc)
                    handler(line)
        except Exception as ex:
            log.error('Pumping    %r    of    cmd(%s)    failed    due    to:    %r', name, cmdline, ex)
            raise CommandError(([('<%s-pump>' % name)] + cmdline), ex)
        finally:
            stream.close()
    cmdline = getattr(process, 'args', '')
    if (not isinstance(cmdline, (tuple, list))):
        cmdline = cmdline.split()
    pumps = []
    if process.stdout:
        pumps.append(('stdout', process.stdout, stdout_handler))
    if process.stderr:
        pumps.append(('stderr', process.stderr, stderr_handler))
    threads = []
    for (name, stream, handler) in pumps:
        t = threading.Thread(target=pump_stream, args=(cmdline, name, stream, decode_streams, handler))
        t.setDaemon(True)
        t.start()
        threads.append(t)
    for t in threads:
        t.join()
    if finalizer:
        return finalizer(process)

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

def handle_process_output(process, stdout_handler, stderr_handler, finalizer=None, decode_streams=True):