2012/8/7 Hamish <[email protected]> > Hamish wrote: >
> for parallelizing an entire function in Python as you want, there's a > method in grass7's i.landsat.rgb(.py) to look at that uses mp.Process. > It's a bit more work since you have to manually ensure that the I/O pipes > get closed. > > https://trac.osgeo.org/grass/browser/grass/trunk/scripts/i.landsat.rgb/i.landsat.rgb.py > > note the above script preserves the serial execution method intact (to > make the imagery method easier to learn), so has ~ double the code than it > actually needs. But I think using the extra wrapper function makes the > real guts of the imagery algorithm easier to read, understand, and > maintain, > and so keeping all the ugly parallelization stuff away is a good thing. > 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?
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
