Skip to content

Commit 638f72e

Browse files
authored
use threadpool in execute task runner (#156)
Signed-off-by: lai <[email protected]>
1 parent a41a586 commit 638f72e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package org.opensearch.ml.task;
77

8+
import static org.opensearch.ml.plugin.MachineLearningPlugin.TASK_THREAD_POOL;
9+
810
import lombok.extern.log4j.Log4j2;
911

1012
import org.opensearch.action.ActionListener;
@@ -61,10 +63,12 @@ public void executeTask(
6163
TransportService transportService,
6264
ActionListener<MLExecuteTaskResponse> listener
6365
) {
64-
Input input = request.getInput();
65-
Output output = MLEngine.execute(input);
66-
MLExecuteTaskResponse response = MLExecuteTaskResponse.builder().output(output).build();
67-
listener.onResponse(response);
66+
threadPool.executor(TASK_THREAD_POOL).execute(() -> {
67+
Input input = request.getInput();
68+
Output output = MLEngine.execute(input);
69+
MLExecuteTaskResponse response = MLExecuteTaskResponse.builder().output(output).build();
70+
listener.onResponse(response);
71+
});
6872
}
6973

7074
}

0 commit comments

Comments
 (0)