Skip to content

Commit 430b16d

Browse files
committed
Test response_sender.send() after closed
1 parent ce3142d commit 430b16d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

qa/L0_backend_python/decoupled/decoupled_test.py

-3
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ def test_decoupled_execute_cancel(self):
288288
log_text = f.read()
289289
self.assertIn("[execute_cancel] Request not cancelled at 1.0 s", log_text)
290290
self.assertIn("[execute_cancel] Request cancelled at ", log_text)
291-
self.assertIn(
292-
"add response output: output: DUMMY_OUT, type: FP32, shape: [1,1]", log_text
293-
)
294291

295292

296293
if __name__ == "__main__":

qa/python_models/execute_cancel/model.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,26 @@ def response_thread(execute_processed_requests, processed_requests):
102102
flags=pb_utils.TRITONSERVER_RESPONSE_COMPLETE_FINAL
103103
)
104104
else:
105+
# test response_sender.send() after it is closed upon checking for
106+
# confirmed request cancelled
105107
dummy_tensor = pb_utils.Tensor(
106108
"DUMMY_OUT", np.array([[1]], np.single)
107109
)
108110
dummy_response = pb_utils.InferenceResponse([dummy_tensor])
109-
response_sender.send(dummy_response)
111+
raised_exception = False
112+
try:
113+
response_sender.send(dummy_response)
114+
except pb_utils.TritonModelException as e:
115+
if (
116+
"Unable to send response. Response sender has been closed."
117+
not in str(e)
118+
):
119+
raise e
120+
raised_exception = True
121+
if not raised_exception:
122+
raise pb_utils.TritonModelException(
123+
"response_sender did not raise an exception on send after closed"
124+
)
110125

111126
thread = threading.Thread(
112127
target=response_thread,

0 commit comments

Comments
 (0)