Skip to content

Instantly share code, notes, and snippets.

@cgibson
Created May 27, 2011 18:47
Show Gist options
  • Save cgibson/995888 to your computer and use it in GitHub Desktop.
Save cgibson/995888 to your computer and use it in GitHub Desktop.
PID lock/release
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