Skip to content

Instantly share code, notes, and snippets.

@wjzhangq
Created April 29, 2019 08:34
Show Gist options
  • Save wjzhangq/744c15ee6d3d7fa0aff095d5743f426f to your computer and use it in GitHub Desktop.
Save wjzhangq/744c15ee6d3d7fa0aff095d5743f426f to your computer and use it in GitHub Desktop.
if __name__ == '__main__':
pid_file = cur_file_dir() + '/logstat.pid'
fp = open(pid_file, 'w')
try:
fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
# another instance is running
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment