mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(proxy): make SettingsStore.clear terminate when the config file owns a key
MutableMapping.clear pops items until the mapping is empty, but __delitem__ keeps config-owned keys, so clear spun forever on any store that had loaded a config file. unittest.mock.patch.dict calls clear on exit, which is why the proxy-infra and proxy-endpoints shards hung at 99 percent until the 20 minute job timeout on every run since the store started refusing config-owned writes Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
307df09792
commit
cf22e4b171
2 changed files with 20 additions and 0 deletions
|
|
@ -98,6 +98,10 @@ class SettingsStore(MutableMapping[str, JsonValue]):
|
|||
def __len__(self) -> int:
|
||||
return sum(1 for _ in self)
|
||||
|
||||
def clear(self) -> None:
|
||||
self._runtime_values = _EMPTY_VALUES
|
||||
self._deleted_runtime_keys = frozenset(key for key in self._keys() if not self.owned_by_config(key))
|
||||
|
||||
def _clear_runtime(self) -> None:
|
||||
self._runtime_values = _EMPTY_VALUES
|
||||
self._deleted_runtime_keys = frozenset()
|
||||
|
|
|
|||
|
|
@ -168,6 +168,22 @@ def test_settings_store_refuses_a_runtime_write_to_a_config_owned_key() -> None:
|
|||
assert store.source("max_parallel_requests") == "config"
|
||||
|
||||
|
||||
@pytest.mark.timeout(10)
|
||||
def test_settings_store_clear_terminates_and_keeps_config_owned_keys() -> None:
|
||||
store: Final = SettingsStore("general_settings")
|
||||
store.load_yaml({"max_parallel_requests": 3})
|
||||
store.apply_db_row("general_settings", {"max_file_size_mb": 9})
|
||||
store["ui_access_mode"] = "admin_only"
|
||||
before: Final = dict(store)
|
||||
|
||||
store.clear()
|
||||
cleared: Final = dict(store)
|
||||
store.update(before)
|
||||
|
||||
assert cleared == {"max_parallel_requests": 3}
|
||||
assert dict(store) == before
|
||||
|
||||
|
||||
def test_settings_store_reports_the_config_owned_keys_a_write_would_change() -> None:
|
||||
store: Final = SettingsStore("general_settings")
|
||||
store.load_yaml({"max_parallel_requests": 3, "ui_access_mode": "admin_only"})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue