Created
May 23, 2018 14:58
-
-
Save Brick85/ba7003c354807c2aa619e2a835c09ef0 to your computer and use it in GitHub Desktop.
linux python check process running. original: https://stackoverflow.com/questions/788411/check-to-see-if-python-script-is-running
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
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