def close(self): loop = asyncio.get_event_loop() loop.run_until_complete(self.wait_for_all_jobs_finished()) if self.status_ == self.SessionStatus.RUNNING: oneflow_api.StopLazyGlobalSession() oneflow_api.DestroyLazyGlobalSession() elif self.status_ == self.SessionStatus.OPEN: oneflow_api.DestroyLazyGlobalSession() else: pass self.status_ = self.SessionStatus.CLOSED
def Close(self): assert self.status_ is SessionStatus.RUNNING self.Sync() assert len(self.job_name2var_name2var_blob_) == 0 del self.var_name2var_blob_ del self.job_name2module_name2module_ self.ReleaseLazyRefBlob() self.ForceReleaseEagerBlobs() oneflow_api.StopLazyGlobalSession() oneflow_api.DestroyLazyGlobalSession() self.status_ = SessionStatus.CLOSED self.resource_ = None if self.eager_config_proto_ctx_: del self.eager_config_proto_ctx_