Skip to content

Waitable cannot be used with MutuallyExclusiveCallbackGroup #264

Closed

Description

@jacobperron

Bug report

Required Info:

  • Operating System:
    • Any
  • Installation type:
    • Any
  • Version or commit hash:
  • DDS implementation:
    • N/A
  • Client library (if applicable):
    • rclpy

Steps to reproduce issue

Execute the following script:

import rclpy
from rclpy.waitable import Waitable
from rclpy.callback_groups import MutuallyExclusiveCallbackGroup


class MutuallyExclusiveWaitable(Waitable):

    def __init__(self):
        super().__init__(MutuallyExclusiveCallbackGroup())

    def is_ready(self, wait_set):
        return False

    def take_data(self):
        return None

    async def execute(self, taken_data):
        pass

    def get_num_entities(self):
        return NumberOfEntities(0, 0, 0, 0, 0)

    def add_to_wait_set(self, wait_set):
        pass

rclpy.init()
waitable = MutuallyExclusiveWaitable()
node = rclpy.create_node('mynode')
node.add_waitable(waitable)
rclpy.spin(node)
rclpy.shutdown()

Expected behavior

No errors.

Actual behavior

Error:

Traceback (most recent call last):
  File "waitable_mux.py", line 30, in <module>
    rclpy.spin(node)
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/__init__.py", line 119, in spin
    executor.spin_once()
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/executors.py", line 557, in spin_once
    handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/executors.py", line 540, in wait_for_ready_callbacks
    return next(self._cb_iter)
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/executors.py", line 388, in _wait_for_ready_callbacks
    waitables.extend(filter(self.can_execute, node.waitables))
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/executors.py", line 339, in can_execute
    return not entity._executor_event and entity.callback_group.can_execute(entity)
  File "/home/jacob/ws/ros2_actions_ws/install/rclpy/lib/python3.5/site-packages/rclpy/callback_groups.py", line 98, in can_execute
    assert weakref.ref(entity) in self.entities
AssertionError

Additional information

The fix should be easy. We should make sure the waitable is added to the callback group before spinning.

Activity

  1. added
    bug
    on Jan 25, 2019
  2. self-assigned this
    on Jan 25, 2019
  3. added
    in progress
    in review
    and removed
    in progress
    on Jan 25, 2019
  4. removed
    in review
    on Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions