<div class="gmail_quote">2012/8/7 Hamish <span dir="ltr"><<a href="mailto:hamish_b@yahoo.com" target="_blank">hamish_b@yahoo.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>Hamish wrote: <br></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
for parallelizing an entire function in Python as you want, there's a<br>
method in grass7's i.landsat.rgb(.py) to look at that uses mp.Process.<br>
It's a bit more work since you have to manually ensure that the I/O pipes<br>
get closed.<br>
  <a href="https://trac.osgeo.org/grass/browser/grass/trunk/scripts/i.landsat.rgb/i.landsat.rgb.py" target="_blank">https://trac.osgeo.org/grass/browser/grass/trunk/scripts/i.landsat.rgb/i.landsat.rgb.py</a><br>
<br>
note the above script preserves the serial execution method intact (to<br>
make the imagery method easier to learn), so has ~ double the code than it<br>
actually needs.  But I think using the extra wrapper function makes the<br>
real guts of the imagery algorithm easier to read, understand, and maintain,<br>
and so keeping all the ugly parallelization stuff away is a good thing.<br>
<span class="HOEnZb"></span></blockquote><div><br>Another cool example. Although I would note that it's very possible to embed the previous type of loop into methods or functions if you wish. I normally write object-oriented though and have heard that the multiprocessing library can only be used with functions because it has trouble passing the objects (although maybe explicitly specifying self would take care of that problem, I've never tried it). Does anybody have experience there? <br>

</div></div>