Another key component of the Asyncio module is the
Future class. This is very similar to
concurrent.futures.Futures, but of course, it is adapted in the main mechanism of Asyncio's event loop. The
asyncio.Future class represents a result (but can also be an exception) that is not yet available. It therefore represents an abstraction of something that is yet to be accomplished.
Callbacks that have to process any results are in fact added to the instances of this class.
import asyncio future = asyncio.Future()
The basic methods of this class are:
cancel(): This cancels the future 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 that is to be run when
remove_done_callback(fn): This removes all instances of a callback...