You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following code to spin up a workerpool.
constpool=Pool(()=>spawn(newWorker('../workers/createCubeMapFaceWorker')),this.#cubeMapWorkerCount >Constants.FacePositions.length// Only makes sense to spin-up 6 - anymore and they are idle.
? Constants.FacePositions.length
: this.#cubeMapWorkerCount
);logger?.info(`${this.#cubeMapWorkerCount} workers spun-up successfully`);letworkerId=1;constpromises=Constants.FacePositions.map(async(face: 'nx'|'ny'|'nz'|'px'|'py'|'pz')=>{returnpool.queue(async({ createCubeMapFaceWorker })=>{returnawaitcreateCubeMapFaceWorker(path,userDetails.organizationDetails,requestDto.tourId,requestDto.cameraId,requestDto.imageVersionName,requestDto.resolutions,requestDto.interpolation,requestDto.maxWidth,requestDto.sharpenLevel,requestDto.compression,face,this.#azureStorageOptions,workerId++);});});try{awaitPromise.all(promises).then(async(results: CubeMapResult[])=>{letinsertUpdateResult=awaitthis.inserUpdateTourImageAudit(results.flatMap(r=>r),requestDto);if(insertUpdateResult.succeeded==null||!insertUpdateResult.succeeded||insertUpdateResult.errors.length>0){responseDto.errors=insertUpdateResult.errors;responseDto.succeeded=false;logger?.warning(`Upload to toursImageAudit collection failed (tourId = ${requestDto.tourId})`);}this.checkAndConstructErrors(results,responseDto);if(responseDto.errors.length>0){responseDto.succeeded=false;httpStatusCode=HttpStatusCode.BadRequest;thrownewError('Cloud persistance and/or database-arbiter failure');}responseDto.succeeded=true;}).catch((exception)=>{varexceptionDetails=Utils.getExceptionMessage(exception);letmessage=`${exceptionDetails.message}\n${exceptionDetails.stack}`;responseDto.errors.push(newRequestError(HttpStatusCode[HttpStatusCode.BadRequest],message));responseDto.succeeded=false;httpStatusCode=HttpStatusCode.BadRequest;logger?.error(message);});logger?.info(`Cubemap processing completed on ${this.#cubeMapWorkerCount} workers, terminating...`);awaitpool.completed(true);awaitpool.terminate();logger?.info(`${this.#cubeMapWorkerCount} workers completed successfully`);}finally{constdir=getImageDir(requestDto.tourId,requestDto.cameraId);if(fs.existsSync(dir)){logger?.info(`Attempting to remove temporary local storage...`);fs.rmSync(dir,{recursive: true,force: true});logger?.info(`Temporary local storage directory \"${dir}\" removed successfully`);}}
This is running great, but the entire program crashes on await pool.terminate();. This does not happen if I use await pool.completed(); but then the app just hangs.
I cannot seem to debug the cause of this and there is an idential issue here (#247). Any help here would be appreciated as the code works perfectly apart from this and I might be doing something silly.
The text was updated successfully, but these errors were encountered:
I have the following code to spin up a workerpool.
This is running great, but the entire program crashes on
await pool.terminate();
. This does not happen if I useawait pool.completed();
but then the app just hangs.I cannot seem to debug the cause of this and there is an idential issue here (#247). Any help here would be appreciated as the code works perfectly apart from this and I might be doing something silly.
The text was updated successfully, but these errors were encountered: