def _run_job(self, job_inst): future = self.event_loop_.create_future() def job_finish_cb(_): self.event_loop_.call_soon_threadsafe(future.set_result, None) job_inst.AddPostFinishCallback(job_finish_cb) oneflow_api.LaunchJob(job_inst) self.job_futures_.append(future)
def LaunchJob(self, job_instance): assert self.status_ is SessionStatus.RUNNING self._IncRunningJobCnt() job_instance.AddPostFinishCallback(lambda _: self._DecRunningJobCnt()) oneflow_api.LaunchJob(job_instance)