From efec0f82e2da30fb5807c39da10d1617d2cb58bc Mon Sep 17 00:00:00 2001
From: James Briggs <35938317+jamescalam@users.noreply.github.com>
Date: Fri, 13 Dec 2024 15:11:23 +0400
Subject: [PATCH] fix: double lock

---
 semantic_router/index/base.py   | 2 +-
 semantic_router/routers/base.py | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/semantic_router/index/base.py b/semantic_router/index/base.py
index 7c88a1e5..cae6d90c 100644
--- a/semantic_router/index/base.py
+++ b/semantic_router/index/base.py
@@ -214,7 +214,7 @@ class BaseIndex(BaseModel):
             if self._is_locked(scope=scope) != value:
                 # in this case, we can set the lock value
                 break
-            if (datetime.now() - start_time).total_seconds() > wait:
+            if (datetime.now() - start_time).total_seconds() < wait:
                 # wait for 2.5 seconds before checking again
                 time.sleep(2.5)
             else:
diff --git a/semantic_router/routers/base.py b/semantic_router/routers/base.py
index 347c5db9..328cf2b7 100644
--- a/semantic_router/routers/base.py
+++ b/semantic_router/routers/base.py
@@ -840,13 +840,9 @@ class BaseRouter(BaseModel):
         return config.get_hash()
 
     def _write_hash(self) -> ConfigParameter:
-        # lock index before writing
-        _ = self.index.lock(value=True)
         config = self.to_config()
         hash_config = config.get_hash()
         self.index._write_config(config=hash_config)
-        # unlock index after writing
-        _ = self.index.lock(value=False)
         return hash_config
 
     def is_synced(self) -> bool:
-- 
GitLab