mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-06 20:25:29 +00:00
Fix pytest event loop warning (#10512)
Fixes: GH-9641
This is a Cursor-generated fix for the following warning from pytest:
```
litellm/caching/llm_caching_handler.py:17
/Users/abramowi/Code/OpenSource/litellm/litellm/caching/llm_caching_handler.py:17: DeprecationWarning: There is no current event loop
event_loop = asyncio.get_event_loop()
```
Cursor prompt:
Fix this pytest warning
```
litellm/caching/llm_caching_handler.py:17
/Users/abramowi/Code/OpenSource/litellm/litellm/caching/llm_caching_handler.py:17: DeprecationWarning: There is no current event loop
event_loop = asyncio.get_event_loop()
```
Fixes https://github.com/BerriAI/litellm/issues/9641
This commit is contained in:
@@ -14,10 +14,10 @@ class LLMClientCache(InMemoryCache):
|
||||
If none, use the key as is.
|
||||
"""
|
||||
try:
|
||||
event_loop = asyncio.get_event_loop()
|
||||
event_loop = asyncio.get_running_loop()
|
||||
stringified_event_loop = str(id(event_loop))
|
||||
return f"{key}-{stringified_event_loop}"
|
||||
except Exception: # handle no current event loop
|
||||
except RuntimeError: # handle no current running event loop
|
||||
return key
|
||||
|
||||
def set_cache(self, key, value, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user