File tree Expand file tree Collapse file tree 2 files changed +17
-15
lines changed
Expand file tree Collapse file tree 2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -329,7 +329,18 @@ absl::StatusOr<BenchmarkInfo*> SessionAdvanced::GetMutableBenchmarkInfo() {
329329 return execution_manager_lock->GetMutableBenchmarkInfo (session_id_);
330330}
331331
332- absl::StatusOr<std::unique_ptr<Engine::Session>> SessionAdvanced::Clone (
332+ absl::StatusOr<std::unique_ptr<Engine::Session>> SessionAdvanced::Clone () {
333+ absl::Status status = absl::OkStatus ();
334+ ASSIGN_OR_RETURN (auto session,
335+ CloneAsync ([&status](absl::StatusOr<Responses> responses) {
336+ status = responses.status ();
337+ }));
338+ RETURN_IF_ERROR (WaitUntilDone ());
339+ RETURN_IF_ERROR (status);
340+ return session;
341+ }
342+
343+ absl::StatusOr<std::unique_ptr<Engine::Session>> SessionAdvanced::CloneAsync (
333344 absl::AnyInvocable<void (absl::StatusOr<Responses>)> callback) {
334345 auto execution_manager_lock = execution_manager_.lock ();
335346 if (execution_manager_lock == nullptr ) {
Original file line number Diff line number Diff line change @@ -91,20 +91,8 @@ class SessionAdvanced : public Engine::Session {
9191 std::optional<BenchmarkInfo> benchmark_info);
9292
9393 // TODO b/409401231 - Call execution manager's release session instead.
94+ // Wait until all tasks are done before destroying the session.
9495 ~SessionAdvanced () override {
95- CancelProcess ();
96- auto execution_manager_lock = execution_manager_.lock ();
97- if (execution_manager_lock == nullptr ) {
98- ABSL_LOG (ERROR) << " Execution manager should not be deleted before "
99- " Session is deleted." ;
100- return ;
101- }
102-
103- auto status = execution_manager_lock->CancelAllTasksInSession (session_id_);
104- if (!status.ok ()) {
105- ABSL_LOG (ERROR) << " Failed to release session: " << status;
106- }
107-
10896 WaitUntilDone ().IgnoreError ();
10997 };
11098
@@ -193,7 +181,10 @@ class SessionAdvanced : public Engine::Session {
193181 }
194182
195183 // TODO b/409401231 - Add unit tests for this function.
196- absl::StatusOr<std::unique_ptr<Session>> Clone (
184+ absl::StatusOr<std::unique_ptr<Session>> Clone () override ;
185+
186+ // TODO b/409401231 - Add unit tests for this function.
187+ absl::StatusOr<std::unique_ptr<Session>> CloneAsync (
197188 absl::AnyInvocable<void (absl::StatusOr<Responses>)> callback) override ;
198189
199190 private:
You can’t perform that action at this time.
0 commit comments