ArcGIS Server arcpy.mapping service hanging with ESRI basemap in mxd

545
4
05-18-2011 08:25 AM
TrentHardy
New Contributor
I am attempting to create an ArcGIS Server geoprocessing service that exports a map. The service runs a python script that uses the arcpy.mapping module to modify map extent, visible layers, layout elements, etc. of an existing mxd, then export the map. I have run into a problem, though, if the mxd has one of the ESRI hosted basemaps and I run the script through the service. If I run the script locally on the server, it works fine. If I run the script through the service, the code hangs when I call ListDataFrames.

mxDoc = arcpy.mapping.MapDocument(r'path\to\mxd')
setVisibleLayers(mxDoc)

def setVisibleLayers(mxDoc):
    dataFrame = arcpy.mapping.ListDataFrames(mxDoc)[0] #code hangs here


The code will sit here until the service reaches its timeout, at which point it logs an error, but then, strangely, it completes (usually, though not always). The job status shows failed, but the map gets exported. Below is the message output from ArcGIS Server:

Job ID: je327da53fea846d184109dd21edd85d4

Job Status: esriJobFailed

Job Messages:

esriJobMessageTypeInformative: Submitted.
esriJobMessageTypeInformative: Executing...
esriJobMessageTypeInformative: Executing (MapPrint): MapPrint Landscape8x11 -12457810 4955286 -12457587 4955538 0 # "a title" "a subtitle" "some comments" pdf A1234
esriJobMessageTypeInformative: Start Time: Wed May 18 08:38:41 2011
esriJobMessageTypeInformative: Running script MapPrint...
esriJobMessageTypeInformative: Setting Visible Layers
esriJobMessageTypeError: Failed.
esriJobMessageTypeError: Execution of job je327da53fea846d184109dd21edd85d4 failed because of crash or termination of the server object.
esriJobMessageTypeInformative: Setting Extent
esriJobMessageTypeInformative: Setting Layout Text
esriJobMessageTypeInformative: Adding basemap
esriJobMessageTypeInformative: Exporting Map
esriJobMessageTypeInformative: Exported E:\arcgisserver\arcgisoutput\PrintableMap\A1234_130573342519.PDF
esriJobMessageTypeInformative: Completed script MapPrint...
esriJobMessageTypeInformative: Succeeded at Wed May 18 08:43:51 2011 (Elapsed Time: 5 minutes 10 seconds)


What more is curious is that in a separate log where I have timestamps, the code will get to the ListDataFrames function quickly and sit there for the 5 minute service timeout. Then in a fraction of a second, the rest of the script will be logged and the map will be generated. This could be related to the logger, but the create timestamp of the exported file coincides with the timestamp in the log for when it says it exports.

Any ideas?
Tags (2)
0 Kudos
4 Replies
KevinBell
Occasional Contributor III
I'd love to see the code!
0 Kudos
TrentHardy
New Contributor
I'd love to see the code!


Here is the code in full.
0 Kudos
ScottDickison
New Contributor III
Did you ever figure this out? I have something very similar happing with an arcpy.mapping script. Works on the server but will not run through the service. Same error message as well.
0 Kudos
DanDeneau
New Contributor III
I'm having a similar problem with the ESRI basemaps. If I run the export locally, it works, but through the service ("Submit Job")...it exports a map, but the ESRI basemaps (i.e. "World_Street_Map") will not display. Anyone have suggestions?
0 Kudos