Multiprocessing Pool and functions with many arguments
Aaron Brady
castironpi at gmail.com
Fri May 1 18:13:34 EDT 2009
On Apr 29, 1:01 pm, "psaff... at googlemail.com"
<psaff... at googlemail.com> wrote:
> I'm trying to get to grips with the multiprocessing module, having
> only used ParallelPython before.
>
> based on this example:
>
> http://docs.python.org/library/multiprocessing.html#using-a-pool-of-w...
>
> what happens if I want my "f" to take more than one argument? I want
> to have a list of tuples of arguments and have these correspond the
> arguments in f, but it keeps complaining that I only have one argument
> (the tuple). Do I have to pass in a tuple and break it up inside f? I
> can't use multiple input lists, as I would with regular map.
>
> Thanks,
>
> Peter
The basic constructor should allow it.
http://docs.python.org/library/multiprocessing.html#the-process-class
p = Process(target=f, args=('bob',))
I think you are imagining:
result = pool.apply_async(f, [ *(1,2,3), *(4,5,6) ] )
But I don't know of a way.
More information about the Python-list
mailing list