Skip to content

Commit

Permalink
Improve error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ateska committed Aug 15, 2023
1 parent f81e7df commit 68cec2d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions asab/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,12 @@ def _on_write(self):
self._loop.remove_writer(self._socket)

while not self._queue.empty():
# TODO: Handle eventual error in writing -> break the cycle and restart on write handler
msg = self._queue.get_nowait()
self._socket.sendall(msg)

try:
self._socket.sendall(msg)
except Exception as e:
print("Error when writing to syslog '{}'".format(self._address), e, file=sys.stderr)
self._enqueue(msg)

def _on_read(self):
try:
Expand Down

0 comments on commit 68cec2d

Please sign in to comment.