running functions in parallel on multiple processors
aleax at aleax.it
Mon Nov 3 15:34:16 CET 2003
Michael Schmitt wrote:
> What is the usual way for running functions in parallel on a
> multiple-processor machine. Actually I want to run a single
> computationally expensive function with different parameter sets.
> Running the functions in different threads doesn't seem to work, because
> of the global interpreter lock.
> Would it help to fork processes, which run the single function with a
> given parameter set? Is there any simple way, how this forked worker
> process can report its result back to the controlling process?
Forked processes could indeed perform whatever computations you
need, and then report their results by writing them to a socket
which the controlling process reads (there are many other IPC
mechanisms, but sockets are often simplest where applicable).
More information about the Python-list