<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic why do some exceptions only occur in debug mode? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-do-some-exceptions-only-occur-in-debug-mode/m-p/687677#M53248</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 00464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (Near).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The offending call was the Near_analysis in line 24 in the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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[0].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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Processing " +fc)


&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.Near_analysis(fc,mappolyfc)


##
##&amp;nbsp; omitted other code......




arcpy.RefreshTOC()
result = arcpy.RefreshActiveView()


del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any suggestions?&amp;nbsp; Surely others are experiencing similar behavior?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:55:42 GMT</pubDate>
    <dc:creator>BillRichards</dc:creator>
    <dc:date>2021-12-12T04:55:42Z</dc:date>
    <item>
      <title>why do some exceptions only occur in debug mode?</title>
      <link>https://community.esri.com/t5/python-questions/why-do-some-exceptions-only-occur-in-debug-mode/m-p/687677#M53248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 00464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (Near).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The offending call was the Near_analysis in line 24 in the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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[0].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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Processing " +fc)


&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.Near_analysis(fc,mappolyfc)


##
##&amp;nbsp; omitted other code......




arcpy.RefreshTOC()
result = arcpy.RefreshActiveView()


del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any suggestions?&amp;nbsp; Surely others are experiencing similar behavior?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-do-some-exceptions-only-occur-in-debug-mode/m-p/687677#M53248</guid>
      <dc:creator>BillRichards</dc:creator>
      <dc:date>2021-12-12T04:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: why do some exceptions only occur in debug mode?</title>
      <link>https://community.esri.com/t5/python-questions/why-do-some-exceptions-only-occur-in-debug-mode/m-p/687678#M53249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in your omitted code section are there try except blocks? I don't know if it is IDE dependent, but I quit using them a long time ago and just learned how to read the errors that appear.&amp;nbsp; I rapidly get the old "in use by other..." error message followed by the litany of the errors history.&amp;nbsp; I have just gotten used to interpreting.&amp;nbsp; I use Pythonwin and Pyscripter... can't say which throws the errors the best (if any)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS&amp;nbsp; &lt;A href="https://docs.python.org/3/tutorial/errors.html" title="https://docs.python.org/3/tutorial/errors.html"&gt;8. Errors and Exceptions — Python 3.5.1 documentation&lt;/A&gt; &lt;/P&gt;&lt;P&gt;those try except blocks are only useful, in my mind, in figuring out how to handle the exception.&amp;nbsp; I just want to fix it and I personally haven't seen a need to carry on if something isn't going to work. Of&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Mar 2016 04:16:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-do-some-exceptions-only-occur-in-debug-mode/m-p/687678#M53249</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-20T04:16:26Z</dc:date>
    </item>
  </channel>
</rss>

