Skip to content

Commit

Permalink
guard_condition docstring
Browse files Browse the repository at this point in the history
Signed-off-by: elian-WSL22H <elian.neppel@posteo.eu>
  • Loading branch information
hubble14567 committed May 18, 2024
1 parent f0bf624 commit eacf51e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rclpy/rclpy/guard_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
class GuardCondition:

def __init__(self, callback, callback_group, context=None):
"""
.. warning:: Users should not create a guard condition with this constructor, instead they
should call :meth:`.Node.create_guard_condition`.
"""
self._context = get_default_context() if context is None else context
with self._context.handle:
self.__gc = _rclpy.GuardCondition(self._context.handle)
Expand All @@ -38,4 +42,8 @@ def handle(self):
return self.__gc

def destroy(self):
"""
.. warning:: Users should not destroy a guard condition with this method, instead they should
call :meth:`.Node.destroy_guard_condition`.
"""
self.handle.destroy_when_not_in_use()
5 changes: 4 additions & 1 deletion rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,10 @@ def create_guard_condition(
callback: Callable,
callback_group: Optional[CallbackGroup] = None
) -> GuardCondition:
"""Create a new guard condition."""
"""Create a new guard condition.
.. warning:: Users should call :meth:`.Node.destroy_guard_condition` to destroy the GuardCondition object.
"""
if callback_group is None:
callback_group = self.default_callback_group
guard = GuardCondition(callback, callback_group, context=self.context)
Expand Down

0 comments on commit eacf51e

Please sign in to comment.