-
Notifications
You must be signed in to change notification settings - Fork 168
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 for ros2param to find node. #802
add timeout option for ros2param to find node. #802
Conversation
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@iuhilnehc-ynos it would be helpful if you can review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use
ros2cli/ros2cli/ros2cli/helpers.py
Line 25 in 1e3f1a0
def wait_for(predicate, timeout, period=0.1): |
wait_for_node
?and then use it similar to
ros2cli/ros2cli/ros2cli/daemon/daemonize.py
Lines 141 to 147 in 1e3f1a0
def daemon_ready(): | |
try: | |
pickler.dump(None) | |
return False | |
except OSError: | |
return True | |
if not wait_for(daemon_ready, timeout): |
Just a tiny minor suggestion.
If the def wait_for_node(node, node_name, include_hidden_nodes=False, timeout=1.0) -> bool:
def check_node_names():
node_names = get_node_names(
node=node, include_hidden_nodes=include_hidden_nodes)
return True if node_name in {n.full_name for n in node_names} else False
return wait_for(check_node_names, timeout) |
BTW: ros2cli/ros2cli/ros2cli/helpers.py Lines 40 to 44 in 1e3f1a0
should be updated, because the predicate() is unnecessary to be called twice under some situations.(It reminded me of the logic similar to https://github.com/gcc-mirror/gcc/blob/83ffe9cde7fe0b4deb0d1b54175fd9b19c38179c/libstdc%2B%2B-v3/include/std/condition_variable#L348-L351.) while not predicate():
if time.time() > deadline:
return predicate()
time.sleep(period)
return True |
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@iuhilnehc-ynos thanks for the suggested fix, all addressed in 776312d |
I believe that same option can be applied at lease |
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up on this!
I have just a small proposal to increase the default timeout. As you see in the tests, 1, second could be too low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - thanks, @fujitatomoya!
@audrow thanks for the review, i will go ahead to merge this. |
address #799
Signed-off-by: Tomoya Fujita Tomoya.Fujita@sony.com