Skip to content

Commit

Permalink
spoolman: fix exception handling
Browse files Browse the repository at this point in the history
Make sure the connection delay isn't skipped if the
error list is full.

Signed-off-by:  Eric Callahan <[email protected]>
  • Loading branch information
Arksine committed Feb 15, 2024
1 parent 67c98f6 commit 65a8271
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions moonraker/components/spoolman.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,20 @@ async def _connect_websocket(self) -> None:
except asyncio.CancelledError:
raise
except Exception as e:
if len(err_list) > 10:
if len(err_list) < 10:
# Allow up to 10 unique errors.
continue
for err in err_list:
if type(err) is type(e) and err.args == e.args:
break
else:
err_list.append(e)
verbose = self.server.is_verbose_enabled()
if verbose:
logging.exception("Failed to connect to Spoolman")
self.server.add_log_rollover_item(
"spoolman_connect", f"Failed to Connect to spoolman: {e}",
not verbose
)
for err in err_list:
if type(err) is type(e) and err.args == e.args:
break
else:
err_list.append(e)
verbose = self.server.is_verbose_enabled()
if verbose:
logging.exception("Failed to connect to Spoolman")
self.server.add_log_rollover_item(
"spoolman_connect", f"Failed to Connect to spoolman: {e}",
not verbose
)
else:
err_list = []
self.ws_connected = True
Expand Down

0 comments on commit 65a8271

Please sign in to comment.