imbajin commented on code in PR #424:
URL: https://github.com/apache/hugegraph-ai/pull/424#discussion_r4579136779


##########
hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py:
##########
@@ -68,7 +48,7 @@ def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
 
         if added_vids:
             vids_to_process = self._extract_names(added_vids) if all_pk_flag 
else added_vids
-            added_embeddings = 
asyncio.run(self._get_embeddings_parallel(vids_to_process))
+            added_embeddings = 
asyncio.run(get_embeddings_parallel(self.embedding, vids_to_process))

Review Comment:
   **⚠️ Keep the async client on a single event loop**
   
   When the same semantic-index operator or embedding instance handles another 
nonempty update, `asyncio.run` creates a new loop after closing the first one, 
but the OpenAI/Ollama async client retains its HTTP connection pool. With a 
reusable keep-alive connection, the second request can fail with `RuntimeError: 
Event loop is closed`, leaving the new vertices unindexed. I reproduced this 
lifecycle with an `httpx.AsyncClient` and a local HTTP/1.1 keep-alive server. 
Please keep the client and event loop lifetimes aligned (or retain the 
synchronous executor path), and cover two updates using the same instance.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to