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

Represents the outcome of a task in the future. More...

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

Public Member Functions

 __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

 _invoke_done_callbacks (self)
 Schedule done callbacks on the executor if possible, else run them directly.
 

Protected Attributes

 _callbacks
 
 _cancelled
 
 _done
 
 _exception
 
 _exception_fetched
 
 _lock
 
 _result
 

Detailed Description

Represents the outcome of a task in the future.

Definition at line 37 of file task.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented in rosros.rclify.task.Task.

Definition at line 43 of file task.py.

◆ __del__()

rosros.rclify.task.Future.__del__ (   self)

Definition at line 58 of file task.py.

Member Function Documentation

◆ __await__()

rosros.rclify.task.Future.__await__ (   self)

Yield while the task is not finished.

Definition at line 63 of file task.py.

◆ _invoke_done_callbacks()

rosros.rclify.task.Future._invoke_done_callbacks (   self)
protected

Schedule done callbacks on the executor if possible, else run them directly.

This function assumes self._lock is not held.

Definition at line 145 of file task.py.

◆ add_done_callback()

rosros.rclify.task.Future.add_done_callback (   self,
  callback 
)

Add a callback to be executed when the task is done.

Callbacks should not raise exceptions.

The callback may be called immediately by this method if the future is already done. If this happens and the callback raises, the exception will be raised by this method.

Parameters
callbacka callback taking the future as an argument to be run when completed

Definition at line 168 of file task.py.

◆ cancel()

rosros.rclify.task.Future.cancel (   self)

Request cancellation of the running task if it is not done already.

Definition at line 69 of file task.py.

◆ cancelled()

rosros.rclify.task.Future.cancelled (   self)

Indicate if the task has been cancelled.

Returns
True if the task was cancelled

Definition at line 81 of file task.py.

◆ done()

rosros.rclify.task.Future.done (   self)

Indicate if the task has finished executing.

Returns
True if the task is finished or raised while it was executing

Definition at line 89 of file task.py.

◆ exception()

rosros.rclify.task.Future.exception (   self)

Get an exception raised by a done task.

Returns
the exception raised by the task

Definition at line 109 of file task.py.

◆ result()

rosros.rclify.task.Future.result (   self)

Get the result of a done task.

Exceptions
Exceptionif one was set during the task.
Returns
The result set by the task

Definition at line 99 of file task.py.

◆ set_exception()

rosros.rclify.task.Future.set_exception (   self,
  exception 
)

Set the exception raised by the task.

Parameters
resultthe output of a long running task

Definition at line 130 of file task.py.

◆ set_result()

rosros.rclify.task.Future.set_result (   self,
  result 
)

Set the result returned by a task.

Parameters
resultthe output of a long running task

Definition at line 118 of file task.py.

Member Data Documentation

◆ _callbacks

rosros.rclify.task.Future._callbacks
protected

Definition at line 54 of file task.py.

◆ _cancelled

rosros.rclify.task.Future._cancelled
protected

Definition at line 47 of file task.py.

◆ _done

rosros.rclify.task.Future._done
protected

Definition at line 45 of file task.py.

◆ _exception

rosros.rclify.task.Future._exception
protected

Definition at line 51 of file task.py.

◆ _exception_fetched

rosros.rclify.task.Future._exception_fetched
protected

Definition at line 52 of file task.py.

◆ _lock

rosros.rclify.task.Future._lock
protected

Definition at line 56 of file task.py.

◆ _result

rosros.rclify.task.Future._result
protected

Definition at line 49 of file task.py.


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