With Jug, how to run nested loops in multiprocessor mode?

for example, the following code starts a task in only 1 process:

from jug import TaskGenerator evaluate = TaskGenerator(evaluate) for p0 in [1,2,3]: for p1 in xrange(10): for p2 in xrange(10,20): for p3 in [True, False]: for p4 in xrange(100): results.append(evaluate(p0,p1,p2,p3,p4)) 

Where to specify the number of processes? thank you

+2
python multiprocessing
source share
1 answer

Posted by jug here.

To run this script, assuming it is a file called script.py , you run the jug execute script.py (not python script.py ).

You can simply run several of them in parallel. If you are using a Unix-like shell, the following should work very well in order to use two processors:

 jug execute script.py & jug execute script.py & 

Different processes will interact with each other, using the file system to share work (this is the default value, you can also use the backis backend if you want to use a cluster of machines that do not use the file system),

You can also use the following to check progress:

 jug status script.py 
+4
source share

All Articles