fix(core): schedule tasks and release waiting threads when continuous task is already running (#30673)
## Current Behavior When a continuous task is already running, parent tasks are not scheduled. ## Expected Behavior When a continuous task is already running, the task orchestrator should schedule the next tasks and release the waiting threads so parent tasks can be scheduled. ## Related Issue(s) Fixes #
This commit is contained in:
parent
48a5d1987e
commit
a1cd4e31ad
@ -629,7 +629,11 @@ export class TaskOrchestrator {
|
|||||||
|
|
||||||
async startContinuousTask(task: Task, groupId: number) {
|
async startContinuousTask(task: Task, groupId: number) {
|
||||||
if (this.runningTasksService.getRunningTasks([task.id]).length) {
|
if (this.runningTasksService.getRunningTasks([task.id]).length) {
|
||||||
// task is already running, we need to poll and wait for the running task to finish
|
// task is already running by another process, we schedule the next tasks
|
||||||
|
// and release the threads
|
||||||
|
await this.scheduleNextTasksAndReleaseThreads();
|
||||||
|
|
||||||
|
// wait for the running task to finish
|
||||||
do {
|
do {
|
||||||
console.log(`Waiting for ${task.id} in another nx process`);
|
console.log(`Waiting for ${task.id} in another nx process`);
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
@ -697,10 +701,7 @@ export class TaskOrchestrator {
|
|||||||
) {
|
) {
|
||||||
await childProcess.getResults();
|
await childProcess.getResults();
|
||||||
} else {
|
} else {
|
||||||
await this.tasksSchedule.scheduleNextTasks();
|
await this.scheduleNextTasksAndReleaseThreads();
|
||||||
// release blocked threads
|
|
||||||
this.waitingForTasks.forEach((f) => f(null));
|
|
||||||
this.waitingForTasks.length = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return childProcess;
|
return childProcess;
|
||||||
@ -797,6 +798,10 @@ export class TaskOrchestrator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await this.scheduleNextTasksAndReleaseThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async scheduleNextTasksAndReleaseThreads() {
|
||||||
await this.tasksSchedule.scheduleNextTasks();
|
await this.tasksSchedule.scheduleNextTasks();
|
||||||
|
|
||||||
// release blocked threads
|
// release blocked threads
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user