Skip to content

Commit 6fbf039

Browse files
authored
Revert "Catch the exception from rate.sleep() if the context is invalid. (#2956)" (#2963)
This reverts commit 10f0186. Signed-off-by: Tomoya Fujita <[email protected]>
1 parent 10f0186 commit 6fbf039

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

rclcpp/src/rclcpp/rate.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ Rate::sleep()
6767
// Calculate the time to sleep
6868
auto time_to_sleep = next_interval - now;
6969
// Sleep (will get interrupted by ctrl-c, may not sleep full time)
70-
try {
71-
// If the context is invalid, an exception will be thrown.
72-
clock_->sleep_for(time_to_sleep);
73-
} catch (const std::runtime_error & e) {
74-
// If it didn't sleep the full time, return false
75-
return false;
76-
}
70+
clock_->sleep_for(time_to_sleep);
7771
return true;
7872
}
7973

rclcpp/test/rclcpp/test_rate.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,3 @@ TEST_F(TestRate, incorrect_constuctor) {
173173
rclcpp::Rate rate(rclcpp::Duration(-1, 0)),
174174
std::invalid_argument("period must be greater than 0"));
175175
}
176-
177-
TEST(TestRateBasic, invalid_context) {
178-
rclcpp::init(0, nullptr);
179-
rclcpp::Rate rate(1.0);
180-
ASSERT_TRUE(rate.sleep());
181-
rclcpp::shutdown();
182-
EXPECT_NO_THROW(rate.sleep());
183-
ASSERT_FALSE(rate.sleep());
184-
}

0 commit comments

Comments
 (0)