Skip to content

Commit

Permalink
upate to generic exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat001 committed Mar 11, 2024
1 parent f6f1676 commit 19f3077
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion optimizely/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def _run(self) -> None:
if self.stopped.wait(self.update_interval):
self.stopped.clear()
break
except (OSError, OverflowError) as err:
except Exception as err:
self.logger.error(
f'Thread for background datafile polling failed. Error: {err}'
)
Expand Down
25 changes: 12 additions & 13 deletions tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,18 @@ def test_fetch_datafile__exception_polling_thread_failed(self, _):
test_response._content = test_datafile

with mock.patch('requests.get', return_value=test_response):
with self.assertRaises(OverflowError):
project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key,
logger=mock_logger,
update_interval=12345678912345)

project_config_manager.stop()

# verify the error log message
log_messages = [args[0] for args, _ in mock_logger.error.call_args_list]
for message in log_messages:
if "Thread for background datafile polling failed. " \
"Error: timestamp too large to convert to C _PyTime_t" not in message:
assert False
project_config_manager = config_manager.PollingConfigManager(sdk_key=sdk_key,
logger=mock_logger,
update_interval=12345678912345)

project_config_manager.stop()

# verify the error log message
log_messages = [args[0] for args, _ in mock_logger.error.call_args_list]
for message in log_messages:
if "Thread for background datafile polling failed. " \
"Error: timestamp too large to convert to C _PyTime_t" not in message:
assert False

def test_is_running(self, _):
""" Test that polling thread is running after instance of PollingConfigManager is created. """
Expand Down

0 comments on commit 19f3077

Please sign in to comment.