automatic multiprocessing

C

Cheng Soon Ong

Hi all,

I'm trying to automate the use of multiprocessing when it is available. The
setting I have is quite simple, with a for loop where the operations inside are
independent of each other. Here's a bit of code. function_inputs is a list of
dictionaries, each of which match the signature of function_handle.

if multiprocessing_present:
# Passing keyword arguments to map still doesn't work
cpus = multiprocessing.Pool()
function_outputs = cpus.map(function_handle, function_inputs)
else:
function_outputs = []
for kwargs in function_inputs:
cur_out = function_handle(**kwargs)
function_outputs.append(cur_out)

Am I missing something here? I cannot seem to get map to pass on keyword arguments.

Thanks in advance,
Cheng Soon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top