Skip to content

Commit

Permalink
[DO NOT MERGE] Revert "Restructure cleaning up of the futures in deco…
Browse files Browse the repository at this point in the history
…upled mode (#309) (#311)"

This reverts commit d2bcb22.
  • Loading branch information
kthui committed Dec 14, 2023
1 parent 8b0fa4c commit 5834064
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/python_be.cc
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ ModelInstanceState::DecoupledMessageQueueMonitor()
std::packaged_task<void()> task([this, response_send_message] {
ResponseSendDecoupled(response_send_message);
});
boost::asio::post(*thread_pool_, std::move(task));
std::future<void> future =
boost::asio::post(*thread_pool_, std::move(task));
futures_.emplace_back(std::move(future));
} else if (
message->Command() == PYTHONSTUB_InferExecRequest ||
message->Command() == PYTHONSTUB_InferStreamExecRequest) {
Expand All @@ -821,7 +823,9 @@ ModelInstanceState::DecoupledMessageQueueMonitor()
bls_execute,
(bls_execute->Command() == PYTHONSTUB_InferStreamExecRequest));
});
boost::asio::post(*thread_pool_, std::move(task));
std::future<void> future =
boost::asio::post(*thread_pool_, std::move(task));
futures_.emplace_back(std::move(future));
}
}
}
Expand Down Expand Up @@ -1875,14 +1879,12 @@ ModelInstanceState::~ModelInstanceState()
Stub()->UpdateHealth();
if (Stub()->IsHealthy()) {
if (model_state->IsDecoupled()) {
// Wait for all the pending tasks to finish.
thread_pool_->wait();
futures_.clear();
// Push a dummy message to signal the thread to terminate.
Stub()->ParentMessageQueue()->Push(DUMMY_MESSAGE);
decoupled_monitor_.join();
} else {
thread_pool_->wait();
}
thread_pool_->wait();
}
// Terminate stub first to allow any last messages to be received by the back
// end before deallocating the queue memory
Expand Down

0 comments on commit 5834064

Please sign in to comment.