Skip to content

Commit b5b4ff9

Browse files
committed
Use new wrapper instead of pybind's
Signed-off-by: Miguel Company <[email protected]>
1 parent ee328c9 commit b5b4ff9

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

rclpy/src/rclpy/clock_event.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <mutex>
2424

2525
#include "clock_event.hpp"
26+
#include "gil_utils.hpp"
2627

2728
namespace py = pybind11;
2829

@@ -48,7 +49,7 @@ void ClockEvent::wait_until(std::shared_ptr<Clock> clock, rcl_time_point_t until
4849
std::chrono::nanoseconds(delta_t.nanoseconds));
4950

5051
// Could be a long wait, release the gil
51-
py::gil_scoped_release release;
52+
gil_scoped_release release;
5253
std::unique_lock<std::mutex> lock(mutex_);
5354
cv_.wait_until(lock, chrono_until, [this]() {return state_;});
5455
}
@@ -58,7 +59,7 @@ void ClockEvent::wait_until_ros(std::shared_ptr<Clock> clock, rcl_time_point_t u
5859
// Check if ROS time is enabled in C++ to avoid TOCTTOU with TimeSource by holding GIL
5960
if (clock->get_ros_time_override_is_enabled()) {
6061
// Could be a long wait, release the gil
61-
py::gil_scoped_release release;
62+
gil_scoped_release release;
6263
std::unique_lock<std::mutex> lock(mutex_);
6364
// Caller must have setup a time jump callback to wake this event
6465
cv_.wait(lock, [this]() {return state_;});

rclpy/src/rclpy/events_executor/events_executor.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "client.hpp"
3838
#include "context.hpp"
39+
#include "gil_utils.hpp"
3940
#include "service.hpp"
4041
#include "subscription.hpp"
4142

@@ -95,7 +96,7 @@ bool EventsExecutor::shutdown(std::optional<double> timeout)
9596

9697
// Block until spinning is done, or timeout. Release the GIL while we block though.
9798
{
98-
py::gil_scoped_release gil_release;
99+
gil_scoped_release gil_release;
99100
std::unique_lock<std::timed_mutex> spin_lock(spinning_mutex_, std::defer_lock);
100101
if (timeout) {
101102
if (!spin_lock.try_lock_for(std::chrono::duration<double>(*timeout))) {
@@ -168,7 +169,7 @@ void EventsExecutor::spin(std::optional<double> timeout_sec, bool stop_after_use
168169
PostOutstandingTasks();
169170
// Release the GIL while we block. Any callbacks on the events queue that want to touch Python
170171
// will need to reacquire it though.
171-
py::gil_scoped_release gil_release;
172+
gil_scoped_release gil_release;
172173
if (timeout_sec) {
173174
const auto timeout_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
174175
std::chrono::duration<double>(*timeout_sec));

rclpy/src/rclpy/wait_set.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string>
2525

2626
#include "exceptions.hpp"
27+
#include "gil_utils.hpp"
2728
#include "wait_set.hpp"
2829

2930
namespace rclpy
@@ -243,7 +244,7 @@ WaitSet::wait(int64_t timeout)
243244

244245
// Could be a long wait, release the GIL
245246
{
246-
py::gil_scoped_release gil_release;
247+
gil_scoped_release gil_release;
247248
ret = rcl_wait(rcl_wait_set_.get(), timeout);
248249
}
249250

0 commit comments

Comments
 (0)