PID File Module

hedwig.pidfile

hedwig.pidfile.pidfile_write(pidfile, pid)

Attempt to write a key for the given process into the file specified.

hedwig.pidfile.pidfile_running(pidfile)

Read the pidfile specified and check if the process is running.

If the pidfile was found then its timestamps are updated (using os.utime). This is to try to avoid the pidfile being automatically removed from temporary directories if a job runs for a very long time.

hedwig.pidfile.pidfile_delete(pidfile)

Attempt to delete the specified pidfile.

hedwig.pidfile._get_process_key(pid)

Generate a string uniquely identifying a processess.

If the cmdline file for this process can be read, then return a string containg the PID and the MD5 digest of that file.

Otherwise just return a string containing the PID.

hedwig.pidfile._check_process_key(key)

Check a process key generated by _get_process_key().

If the key contains spaces, the PID is extracted from the first word and the key is compared to the output of _get_process_key().

Otherwise take the key to be a plain PID and check that the process is still running.