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
|
# Add the message to the deque
|
||||||
logs.append(f'{date}{message}')
|
logs.append(f'{date}{message}')
|
||||||
|
|
||||||
|
tick_count = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# Write the updated messages into Zookeeper
|
# Write the updated messages into Zookeeper
|
||||||
self.zkhandler.write([(('logs.messages', self.node), '\n'.join(logs))])
|
self.zkhandler.write([(('logs.messages', self.node), '\n'.join(logs))])
|
||||||
break
|
break
|
||||||
except Exception:
|
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
|
continue
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue