Skip to content

Instantly share code, notes, and snippets.

@stuntgoat
Created December 31, 2014 07:16
Show Gist options
  • Save stuntgoat/025cbd391491580e6498 to your computer and use it in GitHub Desktop.
Save stuntgoat/025cbd391491580e6498 to your computer and use it in GitHub Desktop.
import sys
from time import sleep
from lockfile.pidlockfile import PIDLockFile
if __name__ == '__main__':
# If we can't acquire a lock in 1 second, raise an exception.
with PIDLockFile('/home/me/script.pid', timeout=1):
while True:
sys.stdout.write('Check /home/me/script.pid for my process id\n')
sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment