File: task1.py

package info (click to toggle)
ipython 0.13.1-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,752 kB
  • sloc: python: 69,537; makefile: 355; lisp: 272; sh: 80; objc: 37
file content (53 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# <nbformat>2</nbformat>

# <markdowncell>

# # Simple task farming example

# <codecell>
from __future__ import print_function

from IPython.parallel import Client

# <markdowncell>

# A `Client.load_balanced_view` is used to get the object used for working with load balanced tasks.

# <codecell>

rc = Client()
v = rc.load_balanced_view()

# <markdowncell>

# Set the variable `d` on all engines:

# <codecell>

rc[:]['d'] = 30

# <markdowncell>

# Define a function that will be our task:

# <codecell>

def task(a):
    return a, 10*d, a*10*d

# <markdowncell>

# Run the task once:

# <codecell>

ar = v.apply(task, 5)

# <markdowncell>

# Print the results:

# <codecell>

print("a, b, c: ", ar.get())