def is_locked(self):
# process is not locked if lock file does not exist
if not os.path.exists(self.path):
return False
# if lock file exists, get pid
with open(self.path, 'r') as f:
lock_pid = f.read().strip()
if not lock_pid:
return False
lock_pid = int(lock_pid)
if psutil.pid_exists(lock_pid):
return True
else:
return False
评论列表
文章目录