diff options
| author | jwansek <eddie.atten.ea29@gmail.com> | 2026-04-24 21:24:48 +0100 |
|---|---|---|
| committer | jwansek <eddie.atten.ea29@gmail.com> | 2026-04-24 21:24:48 +0100 |
| commit | 2e0df084ddcabcb5cd193871fcd31aaaa1104691 (patch) | |
| tree | 765d44c9fe605b24f37ee9fbd74a3bd9e0bf2d5e /autoBackup/autoBackup.py | |
| parent | 001aa38fc8b998171493271c850836506be2bc14 (diff) | |
| download | BetterZFSReplication-2e0df084ddcabcb5cd193871fcd31aaaa1104691.tar.gz BetterZFSReplication-2e0df084ddcabcb5cd193871fcd31aaaa1104691.zip | |
Diffstat (limited to 'autoBackup/autoBackup.py')
| -rw-r--r-- | autoBackup/autoBackup.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/autoBackup/autoBackup.py b/autoBackup/autoBackup.py index 808fd76..28537bf 100644 --- a/autoBackup/autoBackup.py +++ b/autoBackup/autoBackup.py @@ -1,5 +1,6 @@ import truenas_api_client import subprocess +import websocket import datetime import requests import logging @@ -50,10 +51,12 @@ class TrueNASWebsocketsClient(truenas_api_client.JSONRPCClient): for i in range(self.num_retries - 1): try: super().__init__(uri = "ws://%s/api/current" % host, *args, **kwargs) - except truenas_api_client.exc.ClientException as e: - logging.info("'%s', trying again..." % str(e)) + except (truenas_api_client.exc.ClientException, TimeoutError, websocket._exceptions.WebSocketTimeoutException) as e: + logging.info("'%s', connection to host '%s' was iffy, trying again..." % (host, str(e))) else: break + else: + raise ConnectionError("Could not connect to host '%s' after %d retries :c" % (host, self.num_retries)) self.host = host self.username = username self.password = password @@ -70,9 +73,9 @@ class TrueNASWebsocketsClient(truenas_api_client.JSONRPCClient): # We are forced to use username/password instead of API keys if we're using self-certified certificates auth = self.call("auth.login", self.username, self.password) return o - except truenas_api_client.exc.ClientException as e: + except (truenas_api_client.exc.ClientException, TimeoutError, websocket._exceptions.WebSocketTimeoutException) as e: logging.info("'%s', trying again..." % str(e)) - raise ConnectionError("Connection timed out") + raise ConnectionError("Sowwee, connection timed out :c") def __exit__(self, *args, **kwargs): super().__exit__(*args, **kwargs) |
