Summary
turn_coordinator.py:39-43 — the LRU eviction loop breaks at the first locked entry. If the oldest thread lock is held (long-running turn), no eviction happens even if many newer unlocked entries exist. With 512+ concurrent threads and the oldest always busy, the dict grows beyond _MAX_THREAD_LOCKS.
Fix
Continue scanning past locked entries:
while len(_thread_locks) > _MAX_THREAD_LOCKS:
evicted = False
for k, v in list(_thread_locks.items()):
if not v.locked():
_thread_locks.pop(k)
evicted = True
break
if not evicted:
break
Files
apps/server/src/anima_server/services/agent/turn_coordinator.py:39-43
Severity
Low — memory growth beyond intended cap under extreme concurrency.
Summary
turn_coordinator.py:39-43— the LRU eviction loop breaks at the first locked entry. If the oldest thread lock is held (long-running turn), no eviction happens even if many newer unlocked entries exist. With 512+ concurrent threads and the oldest always busy, the dict grows beyond_MAX_THREAD_LOCKS.Fix
Continue scanning past locked entries:
Files
apps/server/src/anima_server/services/agent/turn_coordinator.py:39-43Severity
Low — memory growth beyond intended cap under extreme concurrency.