Skip to content

Commit

Permalink
Add exception handling to the receiver in the debug_logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelberor committed Nov 12, 2024
1 parent 4db8bda commit 09342c2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions code/debugging/src/debug_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,21 @@ def run_listener(listener: Listener):
"""
running = True
while running:
conn = listener.accept()
print(f"[debug_logger]: connection accepted from {listener.last_accepted}")
msg = None
if conn.poll(timeout=2.0):
msg = conn.recv()
if isinstance(msg, str):
if msg.lower() == CLOSE_MSG:
running = False
msg = None
conn.close()
try:
conn = listener.accept()
print(f"[debug_logger]: connection accepted from {listener.last_accepted}")
msg = None
if conn.poll(timeout=2.0):
msg = conn.recv()
if isinstance(msg, str):
if msg.lower() == CLOSE_MSG:
running = False
msg = None
conn.close()
except Exception as error:
eprint(f"Failed to receive message: {error}")
continue

if msg is not None:
with MESSAGES_MUTEX:
MESSAGES.append(msg)
Expand Down

0 comments on commit 09342c2

Please sign in to comment.