diff --git a/litellm/proxy/db/budget_window_spend_writer.py b/litellm/proxy/db/budget_window_spend_writer.py index 02ff9c4f944..d8c2c7c2695 100644 --- a/litellm/proxy/db/budget_window_spend_writer.py +++ b/litellm/proxy/db/budget_window_spend_writer.py @@ -275,13 +275,15 @@ async def commit_window_spend_updates( len(ordered), len(existing_primary_keys), ) - async with prisma_client.db.tx(timeout=_UPSERT_TRANSACTION_TIMEOUT) as db_transaction: - async with db_transaction.batch_() as batcher: - for transaction, seed_base in zip(ordered, seed_bases): - batcher.execute_raw( - _UPSERT_WINDOW_SPEND_SQL, - *_upsert_params(transaction=transaction, seed_base=seed_base, now=now), - ) + async with ( + prisma_client.db.tx(timeout=_UPSERT_TRANSACTION_TIMEOUT) as db_transaction, + db_transaction.batch_() as batcher, + ): + for transaction, seed_base in zip(ordered, seed_bases): + batcher.execute_raw( + _UPSERT_WINDOW_SPEND_SQL, + *_upsert_params(transaction=transaction, seed_base=seed_base, now=now), + ) async def roll_window_spend_row( diff --git a/litellm/proxy/db/db_transaction_queue/window_spend_update_queue.py b/litellm/proxy/db/db_transaction_queue/window_spend_update_queue.py index 8b3b2bf2050..2e7366ce85f 100644 --- a/litellm/proxy/db/db_transaction_queue/window_spend_update_queue.py +++ b/litellm/proxy/db/db_transaction_queue/window_spend_update_queue.py @@ -121,7 +121,7 @@ class WindowSpendUpdateQueue(BaseUpdateQueue): ) """ - def __init__(self): + def __init__(self) -> None: super().__init__() self.update_queue: asyncio.Queue[tuple[WindowSpendTransaction, ...]] = asyncio.Queue( maxsize=LITELLM_ASYNCIO_QUEUE_MAXSIZE