To define a future object, the following syntax must be used:
future = asyncio.Future
The main methods to manage this object are the following:
- cancel(): This cancels the future object and schedules callbacks.
- result(): This returns the result that this future represents.
- exception(): This returns the exception that was set on this future.
- add_done_callback(fn): This adds a callback to be run when future is done.
- remove_done_callback(fn): This removes all instances of a callback from the call when done.
- set_result(result): This marks future as done and sets its result.
- set_exception(exception): This marks future as done and sets an exception.