added cleanup after while

master
agp8x 2014-07-22 10:45:09 +02:00
parent 9de48194c8
commit f68f842fad
1 changed files with 54 additions and 49 deletions

5
all.py
View File

@ -53,6 +53,7 @@ lockname=locks+"/all.lock"
log=open(logs+"/all.log",'a') log=open(logs+"/all.log",'a')
if __name__ == "__main__": if __name__ == "__main__":
try:
while True: while True:
if not os.path.exists(lockname): if not os.path.exists(lockname):
lock=open(lockname,'w') lock=open(lockname,'w')
@ -102,4 +103,8 @@ if __name__ == "__main__":
else: else:
print('lock file active!!') print('lock file active!!')
log.write('lock collision: lock "all" active @ '+time.ctime()+"\n") log.write('lock collision: lock "all" active @ '+time.ctime()+"\n")
except KeyboardInterrupt:
print("Interrupted")
log.write("keyboard-interrupt happened @"+time.ctime()+"\n")
os.remove(lockname)