-
Notifications
You must be signed in to change notification settings - Fork 170
Description
Edit: This is due to spin_once
using the default for timeout which is None
and thus waits infinitely long for the next work item. It seems consistent with rclcpp and rclpy, nevermind the initial report. However when setting the timeout to zero I do it a segfault. See #518 (comment)
@mxgrey on main, it seems that calling executor.spin
with the spin_once
option often blocks and doesn't return anymore. After a while it returns but that can take multiple minutes. I assume this is related to the recent async workers PR #446
I'm able to reproduce with this minimal example.
use rclrs::*;
use std::time::Instant;
fn main() -> Result<(), RclrsError> {
let context = Context::default_from_env()?;
let mut executor = context.create_basic_executor();
let node = executor.create_node("spin_once")?;
let start = Instant::now();
loop {
let spin_options = SpinOptions::spin_once();
// Do something
// Spin the ROS executor once per loop iteration
println!(
"{:?}: Spinning the ROS executor",
Instant::now().duration_since(start)
);
for err in executor.spin(spin_options) {
println!("Error spinning executor: {}", err);
}
}
}
This produces the following output:
Running `target/debug/executor_spin_once`
959ns: Spinning the ROS executor
1.520136ms: Spinning the ROS executor
60.030143ms: Spinning the ROS executor
60.753941ms: Spinning the ROS executor
61.184555ms: Spinning the ROS executor
61.732767ms: Spinning the ROS executor
142.934665ms: Spinning the ROS executor
36.835954541s: Spinning the ROS executor
515.193405684s: Spinning the ROS executor
515.197877282s: Spinning the ROS executor
515.199235729s: Spinning the ROS executor
515.200072409s: Spinning the ROS executor
515.204577531s: Spinning the ROS executor
515.20505359s: Spinning the ROS executor
515.296711749s: Spinning the ROS executor
515.297077096s: Spinning the ROS executor
515.298727927s: Spinning the ROS executor
515.299056657s: Spinning the ROS executor
515.572422362s: Spinning the ROS executor
515.576059027s: Spinning the ROS executor
515.578894946s: Spinning the ROS executor
515.579868122s: Spinning the ROS executor
515.582508512s: Spinning the ROS executor
515.58318564s: Spinning the ROS executor
515.649431917s: Spinning the ROS executor
515.64980933s: Spinning the ROS executor
515.821898359s: Spinning the ROS executor
515.822612154s: Spinning the ROS executor
515.823036055s: Spinning the ROS executor
515.824254962s: Spinning the ROS executor
613.053811476s: Spinning the ROS executor
613.054233761s: Spinning the ROS executor
613.054571505s: Spinning the ROS executor
613.055475553s: Spinning the ROS executor
617.722171324s: Spinning the ROS executor
617.725393116s: Spinning the ROS executor
617.726446308s: Spinning the ROS executor
617.726917001s: Spinning the ROS executor
617.729313804s: Spinning the ROS executor
617.787985176s: Spinning the ROS executor
617.788492489s: Spinning the ROS executor
690.09367819s: Spinning the ROS executor
690.096920025s: Spinning the ROS executor
690.098053481s: Spinning the ROS executor
690.098669179s: Spinning the ROS executor
690.100041836s: Spinning the ROS executor
690.100476962s: Spinning the ROS executor
690.100905686s: Spinning the ROS executor
690.10149059s: Spinning the ROS executor
690.102103217s: Spinning the ROS executor
690.102628434s: Spinning the ROS executor
690.102957312s: Spinning the ROS executor
690.103937821s: Spinning the ROS executor
690.104271151s: Spinning the ROS executor
690.104579495s: Spinning the ROS executor
690.10682558s: Spinning the ROS executor
690.107354417s: Spinning the ROS executor
690.107915881s: Spinning the ROS executor
690.108267309s: Spinning the ROS executor
690.108673793s: Spinning the ROS executor
690.109556136s: Spinning the ROS executor
690.110095288s: Spinning the ROS executor
690.110653009s: Spinning the ROS executor
690.111032795s: Spinning the ROS executor
690.111569118s: Spinning the ROS executor
690.112244265s: Spinning the ROS executor
690.112652687s: Spinning the ROS executor
690.113038728s: Spinning the ROS executor
690.113524153s: Spinning the ROS executor
690.114183974s: Spinning the ROS executor
690.114682071s: Spinning the ROS executor
690.115168713s: Spinning the ROS executor
711.100305683s: Spinning the ROS executor
711.10129357s: Spinning the ROS executor
There also seems to be some effect when running ros2
CLI commands. When running ros2 topic list
for the first time it unlocked for some iterations and then when running ros2 daemon stop/start
it unlocks for some iterations as well.