Add retry to log writes
This commit is contained in:
parent
4d6842f942
commit
b14bc7e3a3
|
@ -228,13 +228,19 @@ 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)
|
||||
# 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue