diff --git a/src/nni_manager/training_service/local/localTrainingService.ts b/src/nni_manager/training_service/local/localTrainingService.ts index a4cdcd5328..fe0223860e 100644 --- a/src/nni_manager/training_service/local/localTrainingService.ts +++ b/src/nni_manager/training_service/local/localTrainingService.ts @@ -355,7 +355,8 @@ class LocalTrainingService implements TrainingService { this.log.info('Stopping local machine training service...'); this.stopping = true; for (const stream of this.jobStreamMap.values()) { - stream.destroy(); + stream.end(0) + stream.emit('end') } if (this.gpuScheduler !== undefined) { await this.gpuScheduler.stop(); @@ -372,7 +373,9 @@ class LocalTrainingService implements TrainingService { if (stream === undefined) { throw new Error(`Could not find stream in trial ${trialJob.id}`); } - stream.destroy(); + //Refer https://github.com/Juul/tail-stream/issues/20 + stream.end(0) + stream.emit('end') this.jobStreamMap.delete(trialJob.id); } } @@ -567,7 +570,6 @@ class LocalTrainingService implements TrainingService { buffer = remain; } }); - this.jobStreamMap.set(trialJobDetail.id, stream); } diff --git a/src/nni_manager/types/tail-stream/index.d.ts b/src/nni_manager/types/tail-stream/index.d.ts index 7ca08cb1bf..f7f3abb376 100644 --- a/src/nni_manager/types/tail-stream/index.d.ts +++ b/src/nni_manager/types/tail-stream/index.d.ts @@ -1,7 +1,8 @@ declare module 'tail-stream' { export interface Stream { on(type: 'data', callback: (data: Buffer) => void): void; - destroy(): void; + end(data: number): void; + emit(data: string): void; } export function createReadStream(path: string): Stream; } \ No newline at end of file