Skip to content

Commit

Permalink
fix: sync lock release logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Jan 11, 2025
1 parent 43a7ed1 commit 2f75578
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 256 deletions.
5 changes: 5 additions & 0 deletions semantic_router/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ def lock(
if self._is_locked(scope=scope) != value:
# in this case, we can set the lock value
break
elif not value:
# if unlocking, we can break immediately — often with Pinecone the
# lock/unlocked state takes a few seconds to update, so locking then
# unlocking quickly will fail without this check
break
if (datetime.now() - start_time).total_seconds() < wait:
# wait for a few seconds before checking again
time.sleep(RETRY_WAIT_TIME)
Expand Down
1 change: 1 addition & 0 deletions semantic_router/routers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ def _execute_sync_strategy(self, strategy: Dict[str, Dict[str, List[Utterance]]]
:param strategy: The sync strategy to execute.
:type strategy: Dict[str, Dict[str, List[Utterance]]]
"""
print(f"strategy: {strategy}")
if strategy["remote"]["delete"]:
data_to_delete = {} # type: ignore
for utt_obj in strategy["remote"]["delete"]:
Expand Down
Loading

0 comments on commit 2f75578

Please sign in to comment.