Why do some tools generate exceptions only while debugging? In other words, when the tool is "run" in ArcMap (10.3.1), the process completes smoothly and as expected, but when "debug" is selected, an exception gets raised - most recently it was:
ExecuteError: ERROR 00464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (Near).
The offending call was the Near_analysis in line 24 in the code below
import arcpy from arcpy import env debug = arcpy.GetParameterAsText(2) if (debug == 'true'): mxdfile = arcpy.GetParameterAsText(3) mxd = arcpy.mapping.MapDocument(mxdfile) else: mxd = arcpy.mapping.MapDocument("CURRENT") mappolyfc = arcpy.GetParameterAsText(1) fcs = arcpy.GetParameter(0) dsource1 = fcs.workspacePath fcs = arcpy.GetParameterAsText(0).split(';') # feature classes multivalue parameter env.workspace = dsource1 f, fldlist = None, None # now process each feature class in fcs for fc in fcs: arcpy.AddMessage("Processing " +fc) result = arcpy.Near_analysis(fc,mappolyfc) ## ## omitted other code...... arcpy.RefreshTOC() result = arcpy.RefreshActiveView() del mxd
Such behavior (raising exceptions only in debug mode) have happened frequently on several projects with various geoprocessing tools and it starts to get wacky! Sometimes the behavior changes after version updates, too.
Any suggestions? Surely others are experiencing similar behavior?