May 2017
Intermediate to advanced
270 pages
6h 18m
English
Futures are a more convenient pattern that can be used to keep track of the results of asynchronous calls. In the preceding code, we saw that rather than returning values, we accept callbacks and pass the results when they are ready. It is interesting to note that, so far, there is no easy way to track the status of the resource.
A future is an abstraction that helps us keep track of the requested resources and that we are waiting to become available. In Python, you can find a future implementation in the concurrent.futures.Future class. A Future instance can be created by calling its constructor with no arguments:
fut = Future() # Result: # <Future at 0x7f03e41599e8 state=pending>
A future represents a value that is not yet available. ...
Read now
Unlock full access