[improvement](chat) Fix the shutdown issue with the Python service. (#405)

This commit is contained in:
lexluo09
2023-11-20 13:24:38 +08:00
committed by GitHub
parent 80ad75503b
commit 2c23c2f574

View File

@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
@@ -25,6 +26,9 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
@Autowired
private EmbeddingUtils embeddingUtils;
@Value("${embedding.operation.sleep.time:3000}")
private Integer embeddingOperationSleepTime;
@Async
@Override
public void onApplicationEvent(DataEvent event) {
@@ -46,6 +50,11 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
if (CollectionUtils.isEmpty(embeddingQueries)) {
return;
}
try {
Thread.sleep(embeddingOperationSleepTime);
} catch (InterruptedException e) {
log.error("", e);
}
embeddingUtils.addCollection(COLLECTION_NAME);
if (event.getEventType().equals(EventType.ADD)) {
embeddingUtils.addQuery(COLLECTION_NAME, embeddingQueries);