[GRASS-user] Crashing during long raster processing loops

Moody, Alex Alex.Moody at idwr.idaho.gov
Wed Aug 21 15:49:00 PDT 2019


Hi all,

I consistently have an issue where I am running long loops for raster processing that crash after 100 iterations or so. Typically the error is a ValueError where "ValueError: the environment variable is longer than 32767 bytes"

This has happened when running scripts in the GUI and when using the grass_session package. A sketch of my loop is as follows:


def doSomething(x):
     user = Session()
     user.open(gisdb=mygisdb, location=mylocation, mapset=mymapset,
                   create_opts='')

     v.surf_idw(....)
     r.out_gdal(...)

     user.close()

def main():
     monthlist = list of dates
     for month in monthlist:
           doSomething(month)

if __name__ == "__main__":
    sys.exit(main())

So I'm opening and closing a session in each loop, which  I hoped would take care of memory Issues I may run into.

I'm using 7.6.1 on a 64-Bit Windows 7. The full error is

Traceback (most recent call last):
  File "D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py", line 82, in <module>
    sys.exit(main())
  File "D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py", line 79, in main
    makeETrSurface(ts)
  File "D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py", line 30, in doSomething
    user = Session()
  File "D:\OSGEO4~1\apps\Python27\lib\site-packages\grass_session\session.py", line 244, in __init__
    self.env = set_grass_path_env(gisbase=self.gisbase, env=self.env)
  File "D:\OSGEO4~1\apps\Python27\lib\site-packages\grass_session\session.py", line 102, in set_grass_path_env
    env['PATH'] += os.pathsep + os.path.join(gisbase, 'extrabin')
  File "D:\OSGEO4~1\apps\Python27\lib\os.py", line 422, in __setitem__
    putenv(key, item)
ValueError: the environment variable is longer than 32767 bytes

Any ideas of how to prevent the ValueError? Perhaps some arguments when calling Session?

Thanks as always,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190821/03d02e9f/attachment.html>


More information about the grass-user mailing list