predict.py now checks for other instances working on same uuid and quits if they exist, closes #27

pull/73/head
Adam Greig 2010-05-31 00:04:23 +01:00
rodzic d4b88b5f42
commit ca40a84fe5
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -122,6 +122,15 @@ def main():
uuid = args[0]
uuid_path = options.preds_path + "/" + uuid + "/"
# Check we're not already running with this UUID
for line in os.popen('ps xa'):
process = " ".join(line.split()[4:])
if process.find(uuid) > 0:
pid = int(line.split()[0])
if pid != os.getpid():
log.error('A process is already running for this UUID, quitting.')
sys.exit(1)
# Make the UUID directory if non existant
if not os.path.exists(uuid_path):
os.mkdir(uuid_path, 0770)