diff --git a/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Packages.rst b/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Packages.rst index 8e2d20780b..e6fb2b6eae 100644 --- a/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Packages.rst +++ b/source/How-To-Guides/Migrating-from-ROS1/Migrating-Python-Packages.rst @@ -170,3 +170,8 @@ In ROS 2: node.get_logger().info('service not available, waiting again...') resp = add_two_ints.call_async(req) rclpy.spin_until_future_complete(node, resp) + +.. warning:: + + Do not use ``rclpy.spin_until_future_complete`` in a ROS 2 callback. + For more details see the :doc:`sync deadlock article <../Sync-Vs-Async>`. diff --git a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst index e8c9f292eb..e26b1dc494 100644 --- a/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst +++ b/source/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.rst @@ -246,7 +246,7 @@ Finally it creates a new ``AddTwoInts`` request object. self.get_logger().info('service not available, waiting again...') self.req = AddTwoInts.Request() -Below the constructor is the ``send_request`` method, which will send the request and return a future that can be passed to ``spin_until_future_complete``: +Below the constructor is the ``send_request`` method, which will send the request and spin until it receives the response or fails. .. code-block:: python @@ -255,7 +255,7 @@ Below the constructor is the ``send_request`` method, which will send the reques self.req.b = b return self.cli.call_async(self.req) -Finally we have the ``main`` method, which constructs a ``MinimalClientAsync`` object, sends the request using the passed-in command-line arguments, calls ``spin_until_future_complete``, and logs the results: +Finally we have the ``main`` method, which constructs a ``MinimalClientAsync`` object, sends the request using the passed-in command-line arguments, calls ``rclpy.spin_until_future_complete`` to wait for the result, and logs the results. .. code-block:: python @@ -273,6 +273,10 @@ Finally we have the ``main`` method, which constructs a ``MinimalClientAsync`` o minimal_client.destroy_node() rclpy.shutdown() +.. warning:: + + Do not use ``rclpy.spin_until_future_complete`` in a ROS 2 callback. + For more details see the :doc:`sync deadlock article <../../../How-To-Guides/Sync-Vs-Async>`. 3.2 Add an entry point ~~~~~~~~~~~~~~~~~~~~~~