smbinterp/tools/multi/pool.py

13 lines
223 B
Python
Raw Normal View History

2009-12-27 09:48:27 -08:00
#!/usr/bin/python
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
pool = Pool(processes = 4)
result = pool.apply_async(f, (10,))
print result.get()
print pool.map(f, range(10))