mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
[improvement](chat) Fix the shutdown issue with the Python service. (#405)
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -25,6 +26,9 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EmbeddingUtils embeddingUtils;
|
private EmbeddingUtils embeddingUtils;
|
||||||
|
|
||||||
|
@Value("${embedding.operation.sleep.time:3000}")
|
||||||
|
private Integer embeddingOperationSleepTime;
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(DataEvent event) {
|
public void onApplicationEvent(DataEvent event) {
|
||||||
@@ -46,6 +50,11 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
|
|||||||
if (CollectionUtils.isEmpty(embeddingQueries)) {
|
if (CollectionUtils.isEmpty(embeddingQueries)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(embeddingOperationSleepTime);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error("", e);
|
||||||
|
}
|
||||||
embeddingUtils.addCollection(COLLECTION_NAME);
|
embeddingUtils.addCollection(COLLECTION_NAME);
|
||||||
if (event.getEventType().equals(EventType.ADD)) {
|
if (event.getEventType().equals(EventType.ADD)) {
|
||||||
embeddingUtils.addQuery(COLLECTION_NAME, embeddingQueries);
|
embeddingUtils.addQuery(COLLECTION_NAME, embeddingQueries);
|
||||||
|
|||||||
Reference in New Issue
Block a user