@@ -459,7 +459,6 @@ Stub::ProcessRequestsDecoupled(RequestBatch* request_batch_shm_ptr)
459459 bool has_exception = false ;
460460 std::string error_string;
461461 std::unique_ptr<PbString> error_string_shm;
462- bool is_coroutine;
463462
464463 ScopedDefer execute_finalize ([this ] { stub_message_queue_->Pop (); });
465464 ScopedDefer _ (
@@ -480,13 +479,6 @@ Stub::ProcessRequestsDecoupled(RequestBatch* request_batch_shm_ptr)
480479
481480 py::object execute_return =
482481 model_instance_.attr (" execute" )(py_request_list);
483- py::module asyncio = py::module::import (" asyncio" );
484-
485- is_coroutine = asyncio.attr (" iscoroutine" )(execute_return).cast <bool >();
486- if (is_coroutine) {
487- execute_return = asyncio.attr (" run" )(execute_return);
488- }
489-
490482 if (!py::isinstance<py::none>(execute_return)) {
491483 throw PythonBackendException (
492484 " Python model '" + model_instance_name_ +
@@ -748,6 +740,12 @@ PYBIND11_EMBEDDED_MODULE(c_python_backend_utils, module)
748740 .def (
749741 " async_exec" ,
750742 [](std::shared_ptr<InferRequest>& infer_request) {
743+ std::unique_ptr<Stub>& stub = Stub::GetOrCreateInstance ();
744+ if (stub->IsDecoupled ()) {
745+ throw PythonBackendException (
746+ " Async BLS request execution is not support in the decoupled "
747+ " API." );
748+ }
751749 py::object loop =
752750 py::module_::import (" asyncio" ).attr (" get_running_loop" )();
753751 py::cpp_function callback = [infer_request]() {
0 commit comments