Skip to content

Commit

Permalink
fix(core): max thread on worker is not respected
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Mar 11, 2022
1 parent f31db14 commit 51508c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
check:
name: Check & Publish
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 45
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
Expand Down
6 changes: 1 addition & 5 deletions core/src/main/java/io/kestra/core/runners/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ public Worker(ApplicationContext applicationContext, int thread) {
this.metricRegistry = applicationContext.getBean(MetricRegistry.class);

ExecutorsUtils executorsUtils = applicationContext.getBean(ExecutorsUtils.class);
this.executors = executorsUtils.maxCachedThreadPool(
Math.min(Runtime.getRuntime().availableProcessors(), thread),
thread,
"worker"
);
this.executors = executorsUtils.maxCachedThreadPool(thread,"worker");
}

@Override
Expand Down
22 changes: 13 additions & 9 deletions core/src/main/java/io/kestra/core/utils/ExecutorsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ public ExecutorService cachedThreadPool(String name) {
);
}

public ExecutorService maxCachedThreadPool(int minThread, int maxThread, String name) {
public ExecutorService maxCachedThreadPool(int maxThread, String name) {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
maxThread,
maxThread,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
threadFactoryBuilder.build(name + "_%d")
);

threadPoolExecutor.allowCoreThreadTimeOut(true);

return this.wrap(
name,
new ThreadPoolExecutor(
minThread,
maxThread,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
threadFactoryBuilder.build(name + "_%d")
)
threadPoolExecutor
);
}

Expand Down

0 comments on commit 51508c2

Please sign in to comment.