Did you ever find a solution to this? I am running into something similar.
Works fine in ArcTools, create the GP Service, go to the web service and it creates a locked file.
I had thought that
del mxd (name of the mxd used)
del arcpy
would work, but it doesn't.
Have you deleted all the objects that have been created in the script behind the GP Service?
ArcGIS Desktop takes care of this (mostly and usually) behind the scenes. But all objects in memory need explicit removal after use.
For example,
#create mxd in memory
mxd = arcpy.mapping.MapDocument(r'some fmxd')
#todo remove mxd
del mxd
If sounds like it is still hanging around in memory and that why it's status is lock.
Susan
can you post your code in the window
Here is the code:
def make_map(wl_id, well_label_text, well_label_nbr, well_label_lat_dd , well_label_long_dd , x_coord , y_coord, trsqq_key , address_of_well , submitted_by , location_source 😞
# ----------- IMPORTS ---------------------------------------------------------- import datetime, sys, arcpy, os, shutil, time # ------------------------------------------------------------------------------------
#=================================================================== # PATHNAMES AND OTHER VARIABLES #=================================================================== blah, blah
#=================================================================== # CREATE POINT #=================================================================== spatialRef = arcpy.Describe(dataset).spatialReference if arcpy.Exists(temp_well_point): arcpy.Delete_management(temp_well_point) print "Old version of well point was deleted." ptx = float(x_coord) pty = float(y_coord) well_point = arcpy.Point(ptx, pty) pointGeometry = arcpy.PointGeometry(well_point, spatialRef) logfile.write("\n... Geometry of point is created...\n") arcpy.CopyFeatures_management(pointGeometry, temp_well_point) arcpy.AddField_management(temp_well_point, "MAP_LABEL", "TEXT", "", "", 20) map_label = "\"" + well_label_nbr + "\"" arcpy.CalculateField_management(temp_well_point, "MAP_LABEL", map_label, "PYTHON") #=================================================================== # CREATE MAP #=================================================================== # Process: Delete pre-existing png... if os.path.exists(well_location_map): os.remove(well_location_map)
# .... Change the extent to the selected area ... df = arcpy.mapping.ListDataFrames(well_mxd,"Layers") [0] newExtent = df.extent newExtent.XMin, newExtent.YMin = xmin, ymin newExtent.XMax, newExtent.YMax = xmax, ymax df.panToExtent(newExtent) #... Add the Layer and Change the Cartography ..... wellLayer = arcpy.mapping.Layer(well_layer) wellLayer.replaceDataSource(workspace_temp, "SHAPEFILE_WORKSPACE", wl_id) arcpy.mapping.AddLayer(df, wellLayer, "TOP") wellLayer.showLabels = True # change the text of the map for elm in arcpy.mapping.ListLayoutElements(well_mxd, "TEXT_ELEMENT"): if elm.text == "latitude_text": elm.text = lat_line if elm.text == "longitude_text": elm.text = long_line if elm.text == "trsqq_text": elm.text = trsqq_line if elm.text == "well_label": elm.text = well_label_line if elm.text == "address_of_well_text": elm.text = address_of_well_line if elm.text == "source_text": elm.text = location_source # ... refresh the map ..... arcpy.RefreshActiveView()
arcpy.mapping.ExportToPNG(well_mxd, well_location_map)
#===================================================================
# CLEANUP
#=================================================================== # ended up deleting the temp point to get rid of the locked files. # in other applications, I may not want to do this. #--------------------------------------------------------------------------------------------------------------------- if arcpy.Exists(temp_well_point): arcpy.Delete_management(temp_well_point)
del well_mxd del arcpy
See above.
In the cleanup section, I ended up deleting the temp point to get rid of the locked files. But in other cases, I may not want to do that.
Hi Dorothy
Geoprocessing Services have changed a bit since the ArcGIS Server 10.1 release. Your code works fine at the Desktop Tool level but when applied to ArcGIS Server is does not know where to find the output result datasets it has generated.
The code will need to be modified to use the ScratchFolder, ScratchGDB and the ScratchWorkspace arcpy variable.
ArcGIS Server goes through and validates the code when the tool is published as a service. A new task is created each time the GP Service is called and a new (temporary) sets of Scratch Workspaces are created.
Did you get any warning messages when you published the tool? It will normally tell you it couldn't figure out the path to the data because it is not know to ArcGIS Server.
http://resources.arcgis.com/en/help/main/10.1/index.html#//001w00000047000000
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.