Skip to content

Instantly share code, notes, and snippets.

@Brick85
Created May 23, 2018 14:58
Show Gist options
  • Save Brick85/ba7003c354807c2aa619e2a835c09ef0 to your computer and use it in GitHub Desktop.
Save Brick85/ba7003c354807c2aa619e2a835c09ef0 to your computer and use it in GitHub Desktop.
import socket
def get_lock(process_name):
get_lock._lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try:
get_lock._lock_socket.bind('\0' + process_name)
return True
except socket.error:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment