Skip to content

Commit

Permalink
improvement: make extend sync
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfeil committed Apr 15, 2024
1 parent 93c27a5 commit ae95434
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/infinity_emb/infinity_emb/inference/batch_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def _schedule(
item=inner,
)
new_prioqueue.append(item)
await self._queue_prio.extend(new_prioqueue)
self._queue_prio.extend(new_prioqueue)

result = await asyncio.gather(
*[self._result_store.wait_for_response(item.item) for item in new_prioqueue]
Expand Down
3 changes: 2 additions & 1 deletion libs/infinity_emb/infinity_emb/inference/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def __init__(self) -> None:
def __len__(self):
return len(self._queue)

async def extend(self, items: list[PrioritizedQueueItem]):
def extend(self, items: list[PrioritizedQueueItem]):
with self._lock_queue_event:
# TODO: _lock event might be conjesting the main thread.
self._queue.extend(items)
self._sync_event.set()

Expand Down

0 comments on commit ae95434

Please sign in to comment.