diff options
Diffstat (limited to 'app/relay/runner.js')
| -rw-r--r-- | app/relay/runner.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/app/relay/runner.js b/app/relay/runner.js index 994dcd4..dbfcb4b 100644 --- a/app/relay/runner.js +++ b/app/relay/runner.js @@ -299,7 +299,8 @@ export function run_task(task, preempt=false, watch=false){ if (! task) return null const module = modules[task.module] if (! module) return { type: 'error', error: "No such module: " + task.module } - const activity = module.activities[task.activity] + const activity = task.activity_object || module.activities[task.activity] + delete task.activity_object if (! activity) return { type: 'error', error: 'No such activity in module: ' + task.module + ' ' + task.activity } return run_task_with_activity(task, module, activity, preempt, watch) } @@ -314,7 +315,7 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa terminate(state.current_gpu_task) } else { console.log('already running GPU task :(', state.current_gpu_task.pid) - return { type: 'error', preempt: false, error: 'task already running on gpu' } + return { type: 'error', busy: true, preempt: false, error: 'task already running on gpu' } } } else if (!interpreter.gpu && state.current_cpu_task.status !== 'IDLE') { if (preempt) { @@ -322,7 +323,7 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa terminate(state.current_cpu_task) } else { console.log('already running CPU task :(') - return { type: 'error', preempt: false, error: 'task already running on cpu' } + return { type: 'error', busy: true, preempt: false, error: 'task already running on cpu' } } } @@ -405,7 +406,17 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa if (task.success && activity.after) { if (activity.after in modules[task.module].activities) { const after_activity = modules[task.module].activities[activity.after] - return run_task_with_activity(task, module, after_activity, preempt, watch) + const task_result = run_task_with_activity(task, module, after_activity, preempt, watch) + if (task_result.busy) { + task.activity_object = after_activity + const interpreter = interpreters[activity.type] + if (interpreter.gpu) { + q.gpu.add_next_task(task) + } else { + q.cpu.add_next_task(task) + } + } + return task_result } else { console.warn('no such after activity:', task.module, activity.after) } |
