Parallel Python Community Forums

Python Forums => Parallel Python Forum => Topic started by: Vitalii on January 14, 2007, 01:24:58 AM



Title: Complete working example with os.popen
Post by: Vitalii on January 14, 2007, 01:24:58 AM
Code: (python)
#!/usr/bin/python
import os
import ppsmp
 
 
def calculate(i, j):
   print os.popen("ps").read()
   return i*j
 
 
n = 10
#start ppsmp server with n processes
srv = ppsmp.Server(n)
 
f = []
 
N = 3
 
for i in range(0,N):
 for j in range(0,N):
     #it might be a little bit more complex if 'calculate' depends on
     f.append(srv.submit(calculate, (i,j), (), ("os",)))
 
for i in range(0,N):
 for j in range(0,N):
    print i, "*", j, "=", f.pop(0)()