5

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

  • 2
    Well...it does (or should) write to disk. It just instantly sends the result off to the client. Thats why it doesn't seem like it has. What client are you using? – KHibma Oct 28 '13 at 16:35
  • I'm using the esri javascript api. Right now the gp service sends back the url to a zip file created on the server, which in my case is always a path back to the gis jobs directory. – bcollins Oct 28 '13 at 16:45
  • 1
    It probably should be returning the file, not a directory. You may need to re-work your script arcpy.SetParameterAsText(#, os.path.join(arcpy.env.scratchFolder, "myfile.zip")) – KHibma Oct 28 '13 at 17:54
  • 1
    Yeah, thats the nature of sync vs. async. Async holds stuff in the jobs directory till the server cleans it up. Sync sends the result onto the client – KHibma Oct 28 '13 at 18:57
  • 1
    I'm not in it for the bounty. I'm here to see working GP Services. :) But for SE sake, I'll add an answer. – KHibma Oct 29 '13 at 19:46
6
+50

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")) 
  • In my case, I was returning a json object using data type String in gp tool, which contained the url to the export package. Not advisable. If you need to persist a file on disk for download with sync gp, you need to have data type File for that output parameter in the gp tool properties to run it synchronous. This difference in configuration for async vs. sync gp services is confusing and I hope esri – bcollins Oct 31 '13 at 17:00
  • Follow up question:gis.stackexchange.com/questions/76106/… – bcollins Oct 31 '13 at 17:36
  • we deleted everything in the jobs directory for our broken service except the .submitted folder (but did delete everything within this folder). And now the tool runs fine as async. – Steve Apr 28 '16 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.