rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
Loading...
Searching...
No Matches
rosros.rclify.task.Task Class Reference

Executes a function or coroutine. More...

Inheritance diagram for rosros.rclify.task.Task:
Inheritance graph

Public Member Functions

 __init__ (self, handler, args=None, kwargs=None, executor=None)
 
 __call__ (self)
 Run or resume a task.
 
 executing (self)
 Check if the task is currently being executed.
 
- Public Member Functions inherited from rosros.rclify.task.Future
 __init__ (self, *executor=None)
 
 __del__ (self)
 
 __await__ (self)
 Yield while the task is not finished.
 
 add_done_callback (self, callback)
 Add a callback to be executed when the task is done.
 
 cancel (self)
 Request cancellation of the running task if it is not done already.
 
 cancelled (self)
 Indicate if the task has been cancelled.
 
 done (self)
 Indicate if the task has finished executing.
 
 exception (self)
 Get an exception raised by a done task.
 
 result (self)
 Get the result of a done task.
 
 set_exception (self, exception)
 Set the exception raised by the task.
 
 set_result (self, result)
 Set the result returned by a task.
 

Protected Member Functions

 _complete_task (self)
 Cleanup after task finished.
 
- Protected Member Functions inherited from rosros.rclify.task.Future
 _invoke_done_callbacks (self)
 Schedule done callbacks on the executor if possible, else run them directly.
 

Protected Attributes

 _args
 
 _executing
 
 _handler
 
 _kwargs
 
 _task_lock
 
- Protected Attributes inherited from rosros.rclify.task.Future
 _callbacks
 
 _cancelled
 
 _done
 
 _exception
 
 _exception_fetched
 
 _lock
 
 _result
 

Detailed Description

Executes a function or coroutine.

This executes either a normal function or a coroutine to completion. On completion it creates tasks for any 'done' callbacks.

Definition at line 187 of file task.py.

Constructor & Destructor Documentation

◆ __init__()

rosros.rclify.task.Task.__init__ (   self,
  executor,
  args = None,
  kwargs = None,
  executor = None 
)
Parameters
executorignored (ROS2 API compatibility stand-in)

Reimplemented from rosros.rclify.task.Future.

Definition at line 189 of file task.py.

Member Function Documentation

◆ __call__()

rosros.rclify.task.Task.__call__ (   self)

Run or resume a task.

This attempts to execute a handler. If the handler is a coroutine it will attempt to await it. If there are done callbacks it will schedule them with the executor.

The return value of the handler is stored as the task result.

Definition at line 217 of file task.py.

◆ _complete_task()

rosros.rclify.task.Task._complete_task (   self)
protected

Cleanup after task finished.

Definition at line 252 of file task.py.

◆ executing()

rosros.rclify.task.Task.executing (   self)

Check if the task is currently being executed.

Returns
True if the task is currently executing

Definition at line 262 of file task.py.

Member Data Documentation

◆ _args

rosros.rclify.task.Task._args
protected

Definition at line 196 of file task.py.

◆ _executing

rosros.rclify.task.Task._executing
protected

Definition at line 205 of file task.py.

◆ _handler

rosros.rclify.task.Task._handler
protected

Definition at line 192 of file task.py.

◆ _kwargs

rosros.rclify.task.Task._kwargs
protected

Definition at line 199 of file task.py.

◆ _task_lock

rosros.rclify.task.Task._task_lock
protected

Definition at line 207 of file task.py.


The documentation for this class was generated from the following file: