Skip to content

Commit ad4a440

Browse files
authored
Reset async_event_loop_ only if initialized (#354)
1 parent 0cdcaf3 commit ad4a440

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/pb_stub.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -945,17 +945,19 @@ void
945945
Stub::Finalize()
946946
{
947947
finalizing_ = true;
948-
// Stop async event loop if created.
949-
if (!py::isinstance<py::none>(async_event_loop_)) {
950-
async_event_loop_.attr("stop")();
951-
}
952-
// Call finalize if exists.
953-
if (initialized_ && py::hasattr(model_instance_, "finalize")) {
954-
try {
955-
model_instance_.attr("finalize")();
948+
if (initialized_) {
949+
// Stop async event loop if created.
950+
if (!py::isinstance<py::none>(async_event_loop_)) {
951+
async_event_loop_.attr("stop")();
956952
}
957-
catch (const py::error_already_set& e) {
958-
LOG_INFO << e.what();
953+
// Call finalize if exists.
954+
if (py::hasattr(model_instance_, "finalize")) {
955+
try {
956+
model_instance_.attr("finalize")();
957+
}
958+
catch (const py::error_already_set& e) {
959+
LOG_INFO << e.what();
960+
}
959961
}
960962
}
961963
#ifdef TRITON_ENABLE_GPU

0 commit comments

Comments
 (0)