Interacting with asynchronous parallel tasks in IPython
In this recipe, we will show how to interact with asynchronous tasks running in parallel with IPython.
Getting ready
You need to start the IPython engines (see the previous recipe). The simplest option is to launch them from the Clusters tab in the notebook dashboard. In this recipe, we use four engines.
How to do it…
- Let's import a few modules:
In [1]: import time import sys from IPython import parallel from IPython.display import clear_output, display from IPython.html import widgets
- We create a
Client
:In [2]: rc = parallel.Client()
- Now, we create a load-balanced view on the IPython engines:
In [3]: view = rc.load_balanced_view()
- We define a simple function for our parallel tasks:
In [4]: def f(x): ...
Get IPython Interactive Computing and Visualization Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.