Tuesday 25 August 2015

python - ArcGIS Server Geoprocessing Service: Good Async, Bad Sync


I'm working a geoprocessing service for ArcGIS 10.1+ written in Python / arcpy.



It runs fine in asynchronous mode, but does not write output to disk when switched to synchronous. I know that synchronous services are supposed to use the arcgisoutput directory, but nothing appears there, or output is deleted before the client can request it.


In forming the output path, I use the arcpy.env.scratchWorkspace variable, which is set to the jobs directory in both async and sync.


What can explain this instability in an ArcGIS Server geoprocessing service when running synchronously?


Thanks in advance



Answer



Async writes to the Job directory and those results are persisted until the Server cleans them up. Sync sends the results back to the client.


With a GP Service you should return a file or data, not a directory (especially with Sync). The framework is meant to return these outputs, it isn't meant to return a folder you can browse to. You'd have to expose output directories and then send back a basic string of that location.


In this case you may need to set your output to file and return it like:


arcpy.SetParameterAsText(#, os.path.join(arcpy.env.scratchFolder, "myfile.zip")) 

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...