Add retry to log writes

This commit is contained in:
Joshua Boniface 2021-07-19 13:11:28 -04:00
parent 4d6842f942
commit b14bc7e3a3
1 changed files with 8 additions and 2 deletions

View File

@ -228,14 +228,20 @@ class ZookeeperLogger(Thread):
# Add the message to the deque
logs.append(f'{date}{message}')
tick_count = 0
while True:
try:
# Write the updated messages into Zookeeper
self.zkhandler.write([(('logs.messages', self.node), '\n'.join(logs))])
break
except Exception:
sleep(0.1)
continue
# The write failed (connection loss, etc.) so retry for 15 seconds
sleep(0.5)
tick_count += 1
if tick_count > 30:
break
else:
continue
return
def stop(self):