mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(proxy_server.py): handle config containing thread locked objects when using get_config_state
This commit is contained in:
parent
c35c137ac1
commit
74bc77b176
2 changed files with 25 additions and 2 deletions
|
|
@ -1657,8 +1657,8 @@ class ProxyConfig:
|
|||
return copy.deepcopy(self.config)
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.debug(
|
||||
"ProxyConfig:get_config_state(): Error returning copy of config state. self.config={}\nError: {}".format(
|
||||
self.config, e
|
||||
"ProxyConfig:get_config_state(): Error returning copy of config state. self.config={}".format(
|
||||
self.config
|
||||
)
|
||||
)
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -1107,6 +1107,29 @@ def test_proxy_config_state_post_init_callback_call():
|
|||
assert config["litellm_settings"]["default_team_settings"][0]["team_id"] == "test"
|
||||
|
||||
|
||||
def test_proxy_config_state_get_config_state_error():
|
||||
"""
|
||||
Ensures that get_config_state does not raise an error when the config is not a valid dictionary
|
||||
"""
|
||||
from litellm.proxy.proxy_server import ProxyConfig
|
||||
import threading
|
||||
|
||||
test_config = {
|
||||
"callback_list": [
|
||||
{
|
||||
"lock": threading.RLock(), # This will cause the deep copy to fail
|
||||
"name": "test_callback",
|
||||
}
|
||||
],
|
||||
"model_list": ["gpt-4", "claude-3"],
|
||||
}
|
||||
|
||||
pc = ProxyConfig()
|
||||
pc.config = test_config
|
||||
config = pc.get_config_state()
|
||||
assert config == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"associated_budget_table, expected_user_api_key_auth_key, expected_user_api_key_auth_value",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue