mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix(base_routing_strategy.py): fix base to handle no running event loop
run in a separate thread
This commit is contained in:
parent
a3d000baaa
commit
3033c40739
2 changed files with 19 additions and 7 deletions
|
@ -22,11 +22,18 @@ class BaseRoutingStrategy(ABC):
|
|||
self.dual_cache = dual_cache
|
||||
self.redis_increment_operation_queue: List[RedisPipelineIncrementOperation] = []
|
||||
if should_batch_redis_writes:
|
||||
asyncio.create_task(
|
||||
self.periodic_sync_in_memory_spend_with_redis(
|
||||
default_sync_interval=default_sync_interval
|
||||
)
|
||||
import threading
|
||||
|
||||
thread = threading.Thread(
|
||||
target=asyncio.run,
|
||||
args=(
|
||||
self.periodic_sync_in_memory_spend_with_redis(
|
||||
default_sync_interval=default_sync_interval
|
||||
),
|
||||
),
|
||||
daemon=True,
|
||||
)
|
||||
thread.start()
|
||||
|
||||
self.in_memory_keys_to_update: set[str] = (
|
||||
set()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue