[GRASS-user] "Parallelization" of Python Script

Daniel Lee lee at isi-solutions.org
Mon Aug 6 08:42:22 PDT 2012


Hi Johannes,

One very simple trick would be to switch off using grass.run_command with
grass.start_command. grass.start_command() spawns a child process that and
continues on to the next line of code, so that you can have several
processes going simultaneously. You just have to make sure that the
processes play nice with each other and don't cause any problems. It's not
the most elegant solution, but it's one that works for many things :)

Best,
Daniel

--

B.Sc. Daniel Lee
Geschäftsführung für Forschung und Entwicklung
ISIS - International Solar Information Solutions GbR
Vertreten durch: Daniel Lee, Nepomuk Reinhard und Nils Räder

Softwarecenter 3
35037 Marburg
Festnetz: +49 6421 379 6256
Mobil: +49 176 6127 7269
E-Mail: Lee at isi-solutions.org
Web: http://www.isi-solutions.org




2012/8/6 Johannes Radinger <johannesradinger at gmail.com>

> Dear GRASS users,
>
> I am running serveral task in GRASS in python scripts. Most of them
> involve for-loops, e.g. to
> run various raster modules with different input. In the end all the result
> maps are mostly aggregated
> to one final map. Anyway the maps are generated during the loops in a
> serial process which takes quite some time.
>
> Thus I thought one could pseudo-"parallelize" the python scripts. As I
> very unexperienced in this field I just
> read the wiki where it states that one could perform the single parts in
> own mapsets and then run the task in parallel.
>
> I attached I short example python script which looks similar to ones I am
> using involving the r.cost module (one
> out of several others) which I run inside a for loop. I tried to
> understand the example in the wiki
> (http://grass.osgeo.org/wiki/Parallelizing_Scripts#Python) but I can't
> transfer it to my task.
>
> Maybe someone is more experienced than me and wants to help to improve the
> speed of such scripts if this
> is generally possible (in GRASS 6). I think this can also be quite
> interesting to other users.
>
> Best regards,
>
> /Johannes
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20120806/cf21337c/attachment-0001.html>


More information about the grass-user mailing list