mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
address P2 feedback: add lock docstring warning, remove redundant mock write
- Add WARNING docstring to _get_shared_session_lock() about not resetting the lock to None while coroutines may be in the recovery path - Remove redundant proxy_server_module.shared_aiohttp_session assignment in mock_init (add_shared_session_to_data overwrites it synchronously)
This commit is contained in:
parent
32ecd24116
commit
ef22144854
2 changed files with 6 additions and 2 deletions
|
|
@ -128,7 +128,12 @@ _shared_session_lock: Optional[asyncio.Lock] = None
|
|||
|
||||
|
||||
def _get_shared_session_lock() -> asyncio.Lock:
|
||||
"""Lazily create the shared session lock (must be called within a running event loop)."""
|
||||
"""Lazily create the shared session lock (must be called within a running event loop).
|
||||
|
||||
WARNING: Do not reset _shared_session_lock to None while any coroutine may be
|
||||
executing the session-recovery path; doing so breaks the double-checked locking
|
||||
guarantee and can cause duplicate session creation.
|
||||
"""
|
||||
global _shared_session_lock
|
||||
if _shared_session_lock is None:
|
||||
_shared_session_lock = asyncio.Lock()
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ async def test_add_shared_session_concurrent_recreation_uses_lock():
|
|||
call_count += 1
|
||||
# Simulate some async work
|
||||
await asyncio.sleep(0.01)
|
||||
proxy_server_module.shared_aiohttp_session = new_session
|
||||
return new_session
|
||||
|
||||
with patch.object(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue