Skip to content

Commit

Permalink
Avoid generating the exception when rcl_send_response times out. (#1136)
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya authored Aug 18, 2023
1 parent 540b809 commit 6cab7e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rclpy/src/rclpy/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ Service::service_send_response(py::object pyresponse, rmw_request_id_t * header)

rcl_ret_t ret = rcl_send_response(rcl_service_.get(), header, raw_ros_response.get());
if (RCL_RET_OK != ret) {
throw RCLError("failed to send response");
if (RCL_RET_TIMEOUT == ret) {
// Warning should use line number of the current stack frame
int stack_level = 1;
PyErr_WarnFormat(
PyExc_RuntimeWarning, stack_level, "failed to send response (timeout): %s",
rcl_get_error_string().str);
rcl_reset_error();
} else {
throw RCLError("failed to send response");
}
}
}

Expand Down

0 comments on commit 6cab7e3

Please sign in to comment.