@@ -677,7 +677,8 @@ ModelInferHandler::StartNewRequest()
677677}
678678
679679bool
680- ModelInferHandler::Process (InferHandler::State* state, bool rpc_ok)
680+ ModelInferHandler::Process (
681+ InferHandler::State* state, bool rpc_ok, bool is_notification)
681682{
682683 // There are multiple handlers registered in the gRPC service.
683684 // Hence, there we can have a case where a handler thread is
@@ -690,8 +691,8 @@ ModelInferHandler::Process(InferHandler::State* state, bool rpc_ok)
690691 // Will delay the Process execution by the specified time.
691692 // This can be used to test the flow when cancellation request
692693 // issued for the request, which is still at START step.
693- LOG_INFO << " Delaying the write of the response by "
694- << state-> delay_process_ms_ << " ms..." ;
694+ LOG_INFO << " Delaying the Process execution by " << state-> delay_process_ms_
695+ << " ms..." ;
695696 std::this_thread::sleep_for (
696697 std::chrono::milliseconds (state->delay_process_ms_ ));
697698 }
@@ -711,11 +712,12 @@ ModelInferHandler::Process(InferHandler::State* state, bool rpc_ok)
711712 // because we will never leave this if body. Refer to PR 7325.
712713 // This is a special case for ModelInferHandler, since we have 2 threads,
713714 // and each of them can process cancellation. ModelStreamInfer has only 1
714- // thread, and cancellation at step START was not reproducible in a
715+ // thread, and cancellation at step START was not reproducible in a
715716 // single thread scenario.
716717 StartNewRequest ();
717718 }
718- bool resume = state->context_ ->HandleCancellation (state, rpc_ok, Name ());
719+ bool resume = state->context_ ->HandleCancellation (
720+ state, rpc_ok, Name (), is_notification);
719721 return resume;
720722 }
721723
@@ -765,7 +767,7 @@ ModelInferHandler::Process(InferHandler::State* state, bool rpc_ok)
765767 std::make_pair (" GRPC_SEND_START" , TraceManager::CaptureTimestamp ()));
766768#endif // TRITON_ENABLE_TRACING
767769
768- state->step_ = COMPLETE;
770+ state->step_ = Steps:: COMPLETE;
769771 state->context_ ->responder_ ->Finish (
770772 inference::ModelInferResponse (), status, state);
771773 }
@@ -1001,7 +1003,7 @@ ModelInferHandler::Execute(InferHandler::State* state)
10011003 }
10021004#endif // TRITON_ENABLE_TRACING
10031005
1004- state->step_ = COMPLETE;
1006+ state->step_ = Steps:: COMPLETE;
10051007 state->context_ ->responder_ ->Finish (error_response, status, state);
10061008 }
10071009}
@@ -1051,6 +1053,17 @@ ModelInferHandler::InferResponseComplete(
10511053 << " , skipping response generation as grpc transaction was "
10521054 " cancelled... " ;
10531055
1056+ if (state->delay_enqueue_ms_ != 0 ) {
1057+ // Will delay PutTaskBackToQueue by the specified time.
1058+ // This can be used to test the flow when cancellation request
1059+ // issued for the request during InferResponseComplete
1060+ // callback right before Process in the notification thread.
1061+ LOG_INFO << " Delaying PutTaskBackToQueue by " << state->delay_enqueue_ms_
1062+ << " ms..." ;
1063+ std::this_thread::sleep_for (
1064+ std::chrono::milliseconds (state->delay_enqueue_ms_ ));
1065+ }
1066+
10541067 // Send state back to the queue so that state can be released
10551068 // in the next cycle.
10561069 state->context_ ->PutTaskBackToQueue (state);
@@ -1113,7 +1126,17 @@ ModelInferHandler::InferResponseComplete(
11131126 std::make_pair (" GRPC_SEND_START" , TraceManager::CaptureTimestamp ()));
11141127#endif // TRITON_ENABLE_TRACING
11151128
1116- state->step_ = COMPLETE;
1129+ if (state->delay_response_completion_ms_ != 0 ) {
1130+ // Will delay the Process execution of state at step COMPLETE by the
1131+ // specified time. This can be used to test the flow when cancellation
1132+ // request issued for the request, which is at InferResponseComplete.
1133+ LOG_INFO << " Delaying InferResponseComplete by "
1134+ << state->delay_response_completion_ms_ << " ms..." ;
1135+ std::this_thread::sleep_for (
1136+ std::chrono::milliseconds (state->delay_response_completion_ms_ ));
1137+ }
1138+
1139+ state->step_ = Steps::COMPLETE;
11171140 state->context_ ->responder_ ->Finish (*response, state->status_ , state);
11181141 if (response_created) {
11191142 delete response;
0 commit comments