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

Make rclpy initialization context-manager aware. #1298

Merged
merged 7 commits into from
Jun 17, 2024

Commits on Jun 11, 2024

  1. Make rclpy initialization context-manager aware.

    This PR does two somewhat controversial things:
    
    1.  It adds in a new "rclpy.managed_init" method to rclpy,
    which would be used with a context manager instead of
    rclpy.init.  I had to do things this way because there
    is no way (as far as I know) for the callee to know whether
    it was called within a context manager or not, and I
    don't think we can reasonably change the semantics of
    rclpy.init() at this point.
    
    2.  It changes the context manager implementation of
    Context so that it does *not* call init() within itself.
    This definitely changes the semantics, but as it stands
    that initialization doesn't make sense because it can't
    take arguments.  I think this change is warranted,
    though we may have to search through documentation and
    examples to make sure this doesn't break anything.
    
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    9604184 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2024

  1. Just return the context.

    That way, we don't need managed_init() anymore.
    
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    25a26a5 View commit details
    Browse the repository at this point in the history
  2. Switch to an intermediate object for initialization.

    That way we can use context managers, but actually properly
    clean up, including uninstalling signal handlers.
    
    We also switch to tracking node resources in the context,
    so that when the context goes away, all nodes associated with
    it are automatically destroyed.
    
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    046defd View commit details
    Browse the repository at this point in the history
  3. Keep backwards compatibility with Context init().

    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    b81046d View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2024

  1. Update initialize_logging documentation.

    Co-authored-by: Shane Loretz <sloretz@openrobotics.org>
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette and sloretz authored Jun 17, 2024
    Configuration menu
    Copy the full SHA
    97682e8 View commit details
    Browse the repository at this point in the history
  2. Update track_node documentation.

    Co-authored-by: Shane Loretz <sloretz@openrobotics.org>
    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette and sloretz authored Jun 17, 2024
    Configuration menu
    Copy the full SHA
    c228f4f View commit details
    Browse the repository at this point in the history
  3. Hold the internal Context lock across {track,untrack}_node.

    Signed-off-by: Chris Lalancette <clalancette@gmail.com>
    clalancette committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    103073a View commit details
    Browse the repository at this point in the history