From df92d9e27c3d62bb764ab512ff7e1c53d93c9af1 Mon Sep 17 00:00:00 2001 From: AndyZe Date: Tue, 17 Oct 2023 09:31:11 -0700 Subject: [PATCH] Document that spin_once() should not be called from multiple threads (#1079) * Document that spin_once() should not be called from multiple threads Signed-off-by: AndyZe Signed-off-by: Shane Loretz --------- Signed-off-by: AndyZe Signed-off-by: Shane Loretz Co-authored-by: Shane Loretz --- rclpy/rclpy/__init__.py | 3 +++ rclpy/rclpy/executors.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/rclpy/rclpy/__init__.py b/rclpy/rclpy/__init__.py index c14184ec4..3c8a9b751 100644 --- a/rclpy/rclpy/__init__.py +++ b/rclpy/rclpy/__init__.py @@ -207,6 +207,9 @@ def spin_once( It is possible the work done is for a node other than the one provided if the global executor has a partially completed coroutine. + This method should not be called from multiple threads with the same node or executor + argument. + :param node: A node to add to the executor to check for work. :param executor: The executor to use, or the global executor if ``None``. :param timeout_sec: Seconds to wait. Block forever if ``None`` or negative. Don't wait if 0. diff --git a/rclpy/rclpy/executors.py b/rclpy/rclpy/executors.py index 52b814b6d..a6ed8e508 100644 --- a/rclpy/rclpy/executors.py +++ b/rclpy/rclpy/executors.py @@ -339,6 +339,8 @@ def spin_once(self, timeout_sec: Optional[float] = None) -> None: A custom executor should use :meth:`wait_for_ready_callbacks` to get work. + This method should not be called from multiple threads. + :param timeout_sec: Seconds to wait. Block forever if ``None`` or negative. Don't wait if 0. """