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

Use a single executor instance for spinning in client_async_callback. (backport #382) #385

Open
wants to merge 1 commit into
base: jazzy
Choose a base branch
from

Commits on May 16, 2024

  1. Use a single executor instance for spinning in client_async_callback. (

    …#382)
    
    In the current code, it calls rclpy.spin_once(), which
    instantiates a new executor, adds the node to it, executors
    one work item, then removes the node and destroys the executor.
    
    Besides being inefficient, the problem with that sequence
    is that adding a node to the executor actually ends up
    being an "event", and so the work item that gets returned
    can be just the work of adding the node, over and over again.
    For reasons I admit I don't fully understand, this only happens
    with rmw_cyclonedds_cpp, not with rmw_fastrtps_cpp.
    
    Regardless, the much more performant thing to do is to create
    an executor at the beginning of the example and to just spin
    on that.  This eliminates adding it to the node constantly,
    and makes this work with all RMWs.
    
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    (cherry picked from commit 7e47aee)
    
    # Conflicts:
    #	rclpy/services/minimal_client/examples_rclpy_minimal_client/client_async_callback.py
    clalancette authored and mergify[bot] committed May 16, 2024
    Configuration menu
    Copy the full SHA
    158ce46 View commit details
    Browse the repository at this point in the history