added cleanup after while
parent
9de48194c8
commit
f68f842fad
5
all.py
5
all.py
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue