Skip to Content
Hands-On Reactive Programming with Python
book

Hands-On Reactive Programming with Python

by Romain Picard
October 2018
Intermediate to advanced
420 pages
10h 26m
English
Packt Publishing
Content preview from Hands-On Reactive Programming with Python

Futures

A Future is an object that is used to store a value that is not available when the future is created, but that will be available at a later time. This is an alternative to callbacks in the typical use case of executing an asynchronous action. An asynchronous function is called, so its return value is not available yet. One way to deal with this is to provide a callback that will be called when the action completes. Another option is to return a future in the asynchronous function and set the result of the action in future once the action has completed. The caller of the asynchronous function can then be notified when future is set.

The following figure shows how a Future object can be used:

Figure 2.6: Using a Future object to wait ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Programming with Design Patterns

Python Programming with Design Patterns

James W. Cooper

Publisher Resources

ISBN: 9781789138726Supplemental Content