O'Reilly logo

IPython Interactive Computing and Visualization Cookbook by Cyrille Rossant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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…

  1. 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
  2. We create a Client:
    In [2]: rc = parallel.Client()
  3. Now, we create a load-balanced view on the IPython engines:
    In [3]: view = rc.load_balanced_view()
  4. We define a simple function for our parallel tasks:
    In [4]: def f(x): ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required