From 04a19c64191533444687a84bcbff138dec314d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20=C5=81usakowski?= Date: Thu, 18 Jul 2019 11:39:54 +0200 Subject: [PATCH] Catch more exceptions in hardware/channel sending threads --- neptune/internal/channels/channels_values_sender.py | 6 +++--- .../internal/threads/hardware_metric_reporting_thread.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/neptune/internal/channels/channels_values_sender.py b/neptune/internal/channels/channels_values_sender.py index c7ee5f058..9185e1348 100644 --- a/neptune/internal/channels/channels_values_sender.py +++ b/neptune/internal/channels/channels_values_sender.py @@ -21,7 +21,7 @@ from future.moves import queue -from neptune.api_exceptions import NeptuneApiException +from neptune.exceptions import NeptuneException from neptune.internal.channels.channels import ChannelIdWithValues, ChannelNameWithTypeAndNamespace, ChannelValue,\ ChannelType, ChannelNamespace from neptune.internal.threads.neptune_thread import NeptuneThread @@ -111,7 +111,7 @@ def _process_batch(self): try: self._send_values(self._values_batch) self._values_batch = [] - except (NeptuneApiException, IOError) as e: + except (NeptuneException, IOError) as e: _logger.warning('Failed to send channel value: %s', e) self._sleep_time = self._SLEEP_TIME - (time.time() - send_start) @@ -154,5 +154,5 @@ def channel_key(value): try: # pylint:disable=protected-access self._experiment._send_channels_values(channels_with_values) - except (NeptuneApiException, IOError) as e: + except (NeptuneException, IOError) as e: _logger.warning('Failed to send channel value: %s', e) diff --git a/neptune/internal/threads/hardware_metric_reporting_thread.py b/neptune/internal/threads/hardware_metric_reporting_thread.py index cba790e82..b9e8f0581 100644 --- a/neptune/internal/threads/hardware_metric_reporting_thread.py +++ b/neptune/internal/threads/hardware_metric_reporting_thread.py @@ -18,6 +18,7 @@ from bravado.exception import HTTPError +from neptune.exceptions import NeptuneException from neptune.internal.threads.neptune_thread import NeptuneThread _logger = logging.getLogger(__name__) @@ -36,7 +37,7 @@ def run(self): try: self.__metric_service.report_and_send(timestamp=time.time()) - except HTTPError as e: + except (NeptuneException, HTTPError) as e: _logger.debug('Unexpected HTTP error in hardware metric reporting thread: %s', e) reporting_duration = time.time() - before