Fix deadlock by using RLock instead of Lock

- Replace threading.Lock() with threading.RLock() (reentrant lock)
- Prevents deadlock when _initialize_chunker/_initialize_code_chunker
  call _initialize_embedding_model while holding the lock
- RLock allows same thread to re-acquire lock safely

Addresses critical PR #17 review feedback
This commit is contained in:
Claude 2025-11-18 23:27:31 +00:00
parent d5fba5ae1a
commit af1013fc1d
No known key found for this signature in database

View file

@ -184,7 +184,7 @@ class Config:
_chunker_instance = None _chunker_instance = None
_code_chunker_instance = None _code_chunker_instance = None
_reranker_instance = None _reranker_instance = None
_init_lock = threading.Lock() # Thread-safety lock for lazy initialization _init_lock = threading.RLock() # Reentrant lock for nested initialization calls
@classmethod @classmethod
def _initialize_embedding_model(cls): def _initialize_embedding_model(cls):