def METHOD_NAME(command, timeout=60, poll_rate=0.1, cwd=None):
    try:  # Python 2
        stdout_file = tempfile.TemporaryFile(bufsize=0)
    except:  # Python 3
        stdout_file = tempfile.TemporaryFile(buffering=0)
    try:
        proc = subprocess.Popen(shlex.split(command), stdout=stdout_file,
                                stderr=subprocess.STDOUT, cwd=cwd, close_fds=True, universal_newlines=True)
        for _ in range(int(timeout/poll_rate)):
            time.sleep(poll_rate)
            if proc.poll() is not None: # process stopped
                break
        if proc.poll() is None:
            proc.kill()  # timeout
            stdout_file.seek(0)
            return (errno.ETIMEDOUT, '%s\n\n...Timeout of %s second(s) is reached!' % (stdout_file.read(), timeout))
        stdout_file.seek(0)
        return (proc.returncode, stdout_file.read())
    finally:
        stdout_file.close()