executing multiple functions in background simultaneously

James Mills prologic at shortcircuit.net.au
Wed Jan 14 02:12:25 CET 2009


On Wed, Jan 14, 2009 at 11:02 AM, Catherine Moroney
<Catherine.M.Moroney at jpl.nasa.gov> wrote:
> I would like to spawn off multiple instances of a function
> and run them simultaneously and then wait until they all complete.
> Currently I'm doing this by calling them as sub-processes
> executable from the command-line.  Is there a way of accomplishing
> the same thing without having to make command-line executables
> of the function call?

Try using the python standard threading module.

Create multiple instances of Thread with target=your_function
Maintain a list of these new Thread instnaces
Join (wait) on them.

pydoc threading.Thread

cheers
James



More information about the Python-list mailing list