From 9067f545af71e565fc51a03b269a7503722f9bdb Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 20 Sep 2026 20:51:01 +0100 Subject: [PATCH] Telnet clients disconnecting shouldn't log an exception --- telnetserver/telnetserver.py | 10 ++++++++-- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/telnetserver/telnetserver.py b/telnetserver/telnetserver.py index 0ba3ec2..06da362 100644 --- a/telnetserver/telnetserver.py +++ b/telnetserver/telnetserver.py @@ -123,13 +123,19 @@ class TelnetServer: except asyncio.CancelledError: pass + except (TimeoutError, ConnectionResetError): + logger.debug("Telnet client connection timed out or was reset by client") except Exception: logger.exception("Exception handling telnet client") finally: logger.debug("Telnet client disconnected") self._clients.remove(writer) - writer.close() - await writer.wait_closed() + try: + writer.close() + await writer.wait_closed() + except (TimeoutError, ConnectionResetError, OSError): + # Socket already closed or timed out, don't care as we were getting rid of it anyway + pass def stop(self): """Stops the telnet server""" diff --git a/templates/add_spot.html b/templates/add_spot.html index 93066c0..0ce2af2 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 885f236..2eb1a07 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -85,7 +85,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 4d81c6e..42b68fe 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 8c917d2..f302c60 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 0cfdd8e..43cbae1 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index dac7020..40ec6df 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 89dd07e..c72fe7a 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -125,8 +125,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index a8ef30c..9ab2cb4 100644 --- a/templates/status.html +++ b/templates/status.html @@ -96,7 +96,7 @@ - +