[llm] Thread-safe mutable globals in llm_core (#709) #832

Closed
sleepy wants to merge 0 commits from fix/llm-core-thread-safety-709 into main
Owner

Fixes #709

Fixes #709
Add threading.Lock synchronization to all module-level mutable globals
in llm_core.py to prevent data races under concurrent async requests:

- _TTLCache: internal lock on get/set/clear/__len__/_purge_expired
- _dead_hosts, _host_fails, _model_activity: shared _state_lock
- _http_client: dedicated _http_client_lock for lazy init

No functional changes; lock granularity keeps contention minimal.
sleepy closed this pull request 2026-06-04 11:42:15 +02:00

Pull request closed

Sign in to join this conversation.
No description provided.