プールを使用してPythonでマルチプロセッシングパッケージを使用しようとしています。
map_async 関数によって呼び出される関数 f があります。
from multiprocessing import Pool
def f(host, x):
print host
print x
hosts = ['1.1.1.1', '2.2.2.2']
pool = Pool(processes=5)
pool.map_async(f,hosts,"test")
pool.close()
pool.join()
このコードには次のエラーがあります。
Traceback (most recent call last):
File "pool-test.py", line 9, in <module>
pool.map_async(f,hosts,"test")
File "/usr/lib/python2.7/multiprocessing/pool.py", line 290, in map_async
result = MapResult(self._cache, chunksize, len(iterable), callback)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 557, in __init__
self._number_left = length//chunksize + bool(length % chunksize)
TypeError: unsupported operand type(s) for //: 'int' and 'str'
f 関数に複数の引数を渡す方法がわかりません。何か方法はありますか?