def read_pid_from_pidfile(pidfile_path):
pid = None<EOL>try:<EOL><INDENT>pidfile = open(pidfile_path, '<STR_LIT:r>')<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>line = pidfile.readline().strip()<EOL>try:<EOL><INDENT>pid = int(line)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>pidfile.close()<EOL><DEDENT>return pid<EOL>
Read the PID recorded in the named PID file.

        Read and return the numeric PID recorded as text in the named
        PID file. If the PID file cannot be read, or if the content is
        not a valid PID, return ``None``.