Skip to content

Commit

Permalink
Auto send response complete final upon response sender destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui committed Oct 4, 2023
1 parent 3a43ef3 commit cac2f2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/response_sender.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -45,6 +45,12 @@ ResponseSender::ResponseSender(
{
}

ResponseSender::~ResponseSender()
{
if (request_address_ != 0 && response_factory_address_ != 0 && !closed_) {
Send(nullptr, TRITONSERVER_RESPONSE_COMPLETE_FINAL);
}
}

void
ResponseSender::Send(
Expand Down Expand Up @@ -189,11 +195,7 @@ ResponseSender::Send(
bool
ResponseSender::IsCancelled()
{
bool is_cancelled = pb_cancel_->IsCancelled();
if (is_cancelled && !closed_) {
Send(nullptr, TRITONSERVER_RESPONSE_COMPLETE_FINAL);
}
return is_cancelled;
return pb_cancel_->IsCancelled();
}

}}} // namespace triton::backend::python
3 changes: 2 additions & 1 deletion src/response_sender.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -38,6 +38,7 @@ class ResponseSender {
intptr_t request_address, intptr_t response_factory_address,
std::unique_ptr<SharedMemoryManager>& shm_pool,
const std::shared_ptr<PbCancel>& pb_cancel);
~ResponseSender();
void Send(std::shared_ptr<InferResponse> response, const uint32_t flags);
bool IsCancelled();

Expand Down

0 comments on commit cac2f2f

Please sign in to comment.