In [1]:
def host(id):
import socket
return "Rank: %d -- %s" % (id, socket.gethostname())
In [2]:
from pathos.helpers import freeze_support
freeze_support()
In [3]:
from pathos.pools import ProcessPool as Pool
pool = Pool()
In [4]:
print("Evaluate 5 items on 2 proc:")
pool.ncpus = 2
res3 = pool.map(host, range(5))
print(pool)
print('\n'.join(res3))
print('')
In [5]:
print("Evaluate 5 items on 10 proc:")
pool.ncpus = 10
res5 = pool.map(host, range(5))
print(pool)
print('\n'.join(res5))
In [ ]: