def _asyc_mesh(self, mesh_id): self._easily_parse() mo = MeshOpt(cad_file=self.cad_file_path, mesh_dir=self.work_path, mesh_config=self.mesh_config, mesh_app=self.mesh_app) mo.ready_mesh_dir() command_dict = mo.get_commands_dict() slurm = Slurm() slurm_id = slurm.send_job(self.work_path, launch_script=self.lanuch_script, username=self.username, total_core=self.num_proc, temp_file="cfmesh_batch_script.sh", job_name=self.mesh_name, **command_dict) log_file = str(Path(self.work_path).joinpath(f"{slurm_id}.out")) err_file = str(Path(self.work_path).joinpath(f"{slurm_id}.err")) DB.write_mesh_status(mesh_id, core_num=self.core_num, slurm_id=slurm_id, log_file=log_file, error_file=err_file) # 开启文件夹监控程序 core_logger.info(f"开始监控 | mesh_id: {mesh_id}") DIR_MONITOR.create_watcher_process( self.work_path, CFMeshResultHandler( mesh_id, (r'.*{slurm_id}\.out'.format(slurm_id=slurm_id), ))) # 阻塞住这个进程, 直到进行转换 while True: state = SlurmDB().query_job_status(slurm_id) if state == 3: break if state in (4, 5): # TODO 生成网格被中断保存 return None time.sleep(10) # TODO 添加异常处理 ori_file = str(Path(self.work_path).joinpath("case.foam")) try: cc = ConvertControler(ori_file=ori_file, des_file=self.des_path, vf_file=self.vf_path, thumb_path=self.thumb_path, convert_type=1) except Exception: core_logger.exception("创建ConvertControler失败") raise ValueError("创建ConvertControler失败") core_logger.info("SU2MeshControler开始进行转换") cv_id = cc.start_actions()[0] print(cv_id) DB.write_mesh_convert(mesh_id, cv_id) return mesh_id