mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +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 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);
|
||||
|
||||
Reference in New Issue
Block a user