Created
May 27, 2011 18:47
-
-
Save cgibson/995888 to your computer and use it in GitHub Desktop.
PID lock/release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ducovar = dict() | |
pid = str(os.getpid()) | |
def pid_exists(): | |
return os.path.isfile(ducovar["PID_FILE"]) | |
def write_pid(): | |
if len(ducovar["PID_FILE"]) == 0: | |
print "Error: invalid pid file [%s]" % ducovar["PID_FILE"] | |
file(ducovar["PID_FILE"], 'w').write(pid) | |
def delete_pid(): | |
if len(ducovar["PID_FILE"]) > 0: | |
os.unlink(ducovar["PID_FILE"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment