Vaclav Petras wrote: > > Does this function mean that: while concurrent r.basin runs on different > > CPUs in the same mapset, there is no interefering by region settings change > > interefering? > > Setting WIND_OVERRIDE (environmental variable) will happen for the current > process, so it won't affect other processes only subprocess which is > desired. (In your case, this won't work if you would use this function > outside of r.basin.) So yes, parallel processes (including g.region) won't > see WIND_OVERRIDE, so they will see and use the original computational > region.
The environment will be inherited by any child processes, so a top-level script can use the same approach (but not use_temp_region() itself) to use a different named region for each subprocess. The main issue with use_temp_region() is that the clean-up function uses the current value of the environment variable to determine which region to delete. This could be fixed by passing a lambda to atexit.register(), e.g. def use_temp_region(): name = "tmp.%s.%d" % (os.path.basename(sys.argv[0]), os.getpid()) run_command("g.region", save=name, overwrite=True) os.environ['WIND_OVERRIDE'] = name atexit.register(lambda: run_command("g.remove", flags='f', quiet=True, type='region', name=name)) -- Glynn Clements <gl...@gclements.plus.com> _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev