How it works...

The concurrent.futures package is a concurrent programming pattern offered by Python. It consists of the future class, which is useful in building concurrent applications in a concise manner.

In the preceding example, req1 and req2 represent sample concurrent methods. In place of a workload, we have included small code fraction that waits for a time interval and returns the current time. Either a callback is given to retrieve the execution outcome in a non-blocking manner, or the Future will wait for the function to complete if yield is used (as illustrated by this recipe).

By leveraging the methods and constructs of concurrent.future efficiently, we can build concurrent and non-blocking applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.61