Skip to content

Commit

Permalink
pass context to wait set (#258)
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodall <william@osrfoundation.org>
  • Loading branch information
wjwwood authored Jan 25, 2019
1 parent 737fd47 commit 0fafaec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rclpy/rclpy/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ def _wait_for_ready_callbacks(self, timeout_sec=None, nodes=None):
entity_count.num_guard_conditions,
entity_count.num_timers,
entity_count.num_clients,
entity_count.num_services)
entity_count.num_services,
self._context.handle)

entities = {
'subscription': (subscriptions, 'subscription_handle'),
Expand Down
13 changes: 10 additions & 3 deletions rclpy/src/rclpy/_rclpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2282,11 +2282,12 @@ rclpy_wait_set_init(PyObject * Py_UNUSED(self), PyObject * args)
unsigned PY_LONG_LONG number_of_timers;
unsigned PY_LONG_LONG number_of_clients;
unsigned PY_LONG_LONG number_of_services;
PyObject * pycontext;

if (!PyArg_ParseTuple(
args, "OKKKKK", &pywait_set, &number_of_subscriptions,
args, "OKKKKKO", &pywait_set, &number_of_subscriptions,
&number_of_guard_conditions, &number_of_timers,
&number_of_clients, &number_of_services))
&number_of_clients, &number_of_services, &pycontext))
{
return NULL;
}
Expand All @@ -2295,9 +2296,15 @@ rclpy_wait_set_init(PyObject * Py_UNUSED(self), PyObject * args)
if (!wait_set) {
return NULL;
}

rcl_context_t * context = (rcl_context_t *)PyCapsule_GetPointer(pycontext, "rcl_context_t");
if (NULL == context) {
return NULL;
}

rcl_ret_t ret = rcl_wait_set_init(
wait_set, number_of_subscriptions, number_of_guard_conditions, number_of_timers,
number_of_clients, number_of_services, rcl_get_default_allocator());
number_of_clients, number_of_services, context, rcl_get_default_allocator());
if (ret != RCL_RET_OK) {
PyErr_Format(PyExc_RuntimeError,
"Failed to initialize wait set: %s", rcl_get_error_string().str);
Expand Down

0 comments on commit 0fafaec

Please sign in to comment.