Skip to content

Commit

Permalink
Reset async_event_loop_ only if initialized (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui authored Apr 16, 2024
1 parent 0cdcaf3 commit ad4a440
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/pb_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -945,17 +945,19 @@ void
Stub::Finalize()
{
finalizing_ = true;
// Stop async event loop if created.
if (!py::isinstance<py::none>(async_event_loop_)) {
async_event_loop_.attr("stop")();
}
// Call finalize if exists.
if (initialized_ && py::hasattr(model_instance_, "finalize")) {
try {
model_instance_.attr("finalize")();
if (initialized_) {
// Stop async event loop if created.
if (!py::isinstance<py::none>(async_event_loop_)) {
async_event_loop_.attr("stop")();
}
catch (const py::error_already_set& e) {
LOG_INFO << e.what();
// Call finalize if exists.
if (py::hasattr(model_instance_, "finalize")) {
try {
model_instance_.attr("finalize")();
}
catch (const py::error_already_set& e) {
LOG_INFO << e.what();
}
}
}
#ifdef TRITON_ENABLE_GPU
Expand Down

0 comments on commit ad4a440

Please sign in to comment.