# Revision history [back]

spin_once() is typically used to integrate with another thing that needs the same thread (like if ROS and Qt need the main thread, they can take turns "spinning" to share the time), but can be used to do what you're doing.

A better way to do this (in my opinion) would be to use a future and store the data in it and complete the future when the data set is completed, that way you can use:

https://github.com/ros2/rclpy/blob/1a6c662400aa8eaa578503748e2a16c2dde27d65/rclpy/rclpy/executors.py#L266-L269

However, are you just waiting for "at least one sample" in each slot or do you want a matching set? I.e. do you want sequence number 1 of each reading? Put another way, what happens when obs1() gets called more than once before obs6() is called for the first time? Is that ok?

More generally, however, this is something that is commonly needed and is traditionally covered in the message_filters package from ROS 1. This has been paritially ported to ROS 2, but I don't know the state of it:

https://github.com/ros2/message_filters/blob/master/src/message_filters/__init__.py