@@ -659,6 +659,7 @@ Stub::ProcessRequests(RequestBatch* request_batch_shm_ptr)
659
659
bool has_exception = false ;
660
660
std::string error_string;
661
661
std::unique_ptr<PbString> error_string_shm;
662
+ std::string err_message;
662
663
663
664
ScopedDefer execute_finalize ([this ] { stub_message_queue_->Pop (); });
664
665
ScopedDefer _ (
@@ -705,11 +706,10 @@ Stub::ProcessRequests(RequestBatch* request_batch_shm_ptr)
705
706
}
706
707
707
708
if (has_exception) {
708
- std::string err_message =
709
- std::string (
710
- " Failed to process the request(s) for model '" + name_ +
711
- " ', message: " ) +
712
- error_string;
709
+ err_message = std::string (
710
+ " Failed to process the request(s) for model '" + name_ +
711
+ " ', message: " ) +
712
+ error_string;
713
713
LOG_ERROR << err_message.c_str ();
714
714
if (!response_batch) {
715
715
response_batch = shm_pool_->Construct <char >(
@@ -718,12 +718,11 @@ Stub::ProcessRequests(RequestBatch* request_batch_shm_ptr)
718
718
ResponseBatch* response_batch_shm_ptr = reinterpret_cast <ResponseBatch*>(
719
719
response_batch.value ().data_ .get () + sizeof (IPCMessageShm));
720
720
721
- response_batch_shm_ptr =
722
- reinterpret_cast <ResponseBatch*>(response_batch.value ().data_ .get ());
723
721
response_batch_shm_ptr->has_error = true ;
724
722
error_string_shm = PbString::Create (shm_pool_, err_message);
725
723
response_batch_shm_ptr->error = error_string_shm->ShmHandle ();
726
724
response_batch_shm_ptr->is_error_set = true ;
725
+ response_batch_shm_ptr->batch_size = 0 ;
727
726
// Once the error is sent to the backend, the backend is supposed to close
728
727
// all response factories if not already closed, so closing all response
729
728
// senders if not already closed to prevent the model from sending more
@@ -732,23 +731,25 @@ Stub::ProcessRequests(RequestBatch* request_batch_shm_ptr)
732
731
InferRequest* request = py_request.cast <InferRequest*>();
733
732
request->GetResponseSender ()->Close ();
734
733
}
735
- }
736
-
737
- if (!response_batch) {
738
- response_batch = shm_pool_->Construct <char >(
739
- sizeof (ResponseBatch) + sizeof (IPCMessageShm));
734
+ } else {
735
+ if (!response_batch) {
736
+ response_batch = shm_pool_->Construct <char >(
737
+ sizeof (ResponseBatch) + sizeof (IPCMessageShm));
738
+ ResponseBatch* response_batch_shm_ptr = reinterpret_cast <ResponseBatch*>(
739
+ response_batch.value ().data_ .get () + sizeof (IPCMessageShm));
740
+ response_batch_shm_ptr->batch_size = 0 ;
741
+ }
740
742
ResponseBatch* response_batch_shm_ptr = reinterpret_cast <ResponseBatch*>(
741
743
response_batch.value ().data_ .get () + sizeof (IPCMessageShm));
742
- response_batch_shm_ptr->batch_size = 0 ;
744
+ response_batch_shm_ptr->has_error = false ;
745
+ response_batch_shm_ptr->is_error_set = false ;
743
746
}
744
- ResponseBatch* response_batch_shm_ptr = reinterpret_cast <ResponseBatch*>(
745
- response_batch.value ().data_ .get () + sizeof (IPCMessageShm));
746
- response_batch_shm_ptr->has_error = false ;
747
- response_batch_shm_ptr->is_error_set = false ;
747
+
748
748
execute_response = IPCMessage::Create (
749
749
reinterpret_cast <IPCMessageShm*>(response_batch.value ().data_ .get ()),
750
750
response_batch.value ().handle_ );
751
- execute_response->Args () = response_batch.value ().handle_ ;
751
+ execute_response->Args () =
752
+ response_batch.value ().handle_ + sizeof (IPCMessageShm);
752
753
execute_response->InlineResponse () = false ;
753
754
execute_response->Command () = PYTHONSTUB_ExecuteResponse;
754
755
_.Complete ();
0 commit comments