From ef09eba6f03f70582268726ed08a7d22d13eb68d Mon Sep 17 00:00:00 2001 From: Matthew Kotila Date: Fri, 29 Sep 2023 14:29:22 -0700 Subject: [PATCH] Throw exception when request period larger than max tokens rather than infinite loop (#403) * Throw exception when request period larger than max tokens rather than infinite loop * Update periodic_concurrency_worker.cc --- src/c++/perf_analyzer/periodic_concurrency_worker.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/c++/perf_analyzer/periodic_concurrency_worker.cc b/src/c++/perf_analyzer/periodic_concurrency_worker.cc index 9fbaee3cc..9af3a9d87 100644 --- a/src/c++/perf_analyzer/periodic_concurrency_worker.cc +++ b/src/c++/perf_analyzer/periodic_concurrency_worker.cc @@ -55,6 +55,15 @@ PeriodicConcurrencyWorker::WorkerCallback(uint32_t infer_context_id) period_completed_callback_(); } if (ctxs_.at(infer_context_id)->HasReceivedFinalResponse()) { + bool has_not_completed_period{ + ctxs_.at(infer_context_id)->GetNumResponsesForCurrentRequest() < + request_period_}; + if (has_not_completed_period) { + throw std::runtime_error( + "Request received final response before request period was reached. " + "Request period must be at most the total number of responses " + "received by any request."); + } request_completed_callback_(); } }