Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout option to call_service messages #984

Draft
wants to merge 1 commit into
base: ros2
Choose a base branch
from

Conversation

bjsowa
Copy link
Collaborator

@bjsowa bjsowa commented Dec 22, 2024

Public API Changes
Adds timeout option to call_service messages

Description
If during calling a service, the Service Server dies, the ServiceCaller will get stuck waiting for response. This also makes the whole protocol stuck if call_services_in_new_threads option is not set.

This PR adds a response timeout parameter to ServiceCaller and adds an optional timeout option to call_service messages with a default value of 5 seconds.

If the API change gets accepted I will finish this PR by adding tests that cover this feature

@bjsowa bjsowa requested a review from sea-bass December 22, 2024 09:30
@@ -81,6 +81,7 @@ def call_service(self, message):
fragment_size = message.get("fragment_size", None)
compression = message.get("compression", "none")
args = message.get("args", [])
timeout = message.get("timeout", 5.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the previous default was to never time out. Should this continue to be the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to retain current behavior, it should by default never timeout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I think we could change the defaults for rolling and future distros. @sea-bass what do you think about branching out for Jazzy ?

while rclpy.ok() and not future.done():
start_time = time.monotonic()
while (
rclpy.ok() and not future.done() and time.monotonic() - start_time < server_response_timeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no option to never time out? Like a -1 value or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could treat any non-positive value as "no timeout"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants