I want to send requests from a web frontend to GRASS GIS. I am currently using the Python Web Framework FastAPI for communication between the frontend and GRASS GIS.
I built the API as follows:
- First I start GRASS GIS with the
grass
command, because I want to use the PyGRASS library - Then I'm using the GRASS GIS Python distribution to start the FastAPI
- If the API receives a request, a new GRASS session will be created with the following command:
gsetup.init('grassdata', 'location01', 'PERMANENT')
. That means in case of multiple requests at once, the API will create multiple sessions - Each request has different region parameters. These parameters are passed individually to GRASS GIS with the
g.Region
module - GRASS should now start with the actual geoprocessing and return the result to the API
Current behavior:
- If there are two parallel requests, the first request is not processed correctly
- Request 1 mostly contains elements from the geoprocessing of request 2
Unfortunately, the guide Parallel GRASS jobs did not help me. I don't understand how the environment variable WIND_OVERRIDE
can help to use different GRASS GIS regions at the same time. In the end, the environment variable is getting overwritten with every request. So if request 2 is started a few milliseconds after request 1, request 2 will overwrite request 1's region.
Actinia should have had the same problem. If I understand the code and documentation correctly, the actinia developers are using a Redis queue as a workaround. The queue ensures that each actinia node only processes one request at a time. Is that right?