Skip to content

Mpirnovar update error #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions optimizely/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ 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'Provided update_interval value may be too big. Error: {err}'
f'Thread for background datafile polling failed. Error: {err}'
)
raise

Expand Down
26 changes: 26 additions & 0 deletions tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,32 @@ def test_fetch_datafile__request_exception_raised(self, _):
self.assertEqual(test_headers['Last-Modified'], project_config_manager.last_modified)
self.assertIsInstance(project_config_manager.get_config(), project_config.ProjectConfig)

def test_fetch_datafile__exception_polling_thread_failed(self, _):
""" Test that exception is raised when polling thread stops. """
sdk_key = 'some_key'
mock_logger = mock.Mock()

test_headers = {'Last-Modified': 'New Time'}
test_datafile = json.dumps(self.config_dict_with_features)
test_response = requests.Response()
test_response.status_code = 200
test_response.headers = test_headers
test_response._content = test_datafile

with mock.patch('requests.get', return_value=test_response):
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. """
with mock.patch('optimizely.config_manager.PollingConfigManager.fetch_datafile'):
Expand Down