<?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 Re: Imported toolbox runs very slowly in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1553493#M73109</link>
    <description>&lt;P&gt;The following code seems to work fine for me (speed wise when compared to manual runs).&lt;/P&gt;&lt;P&gt;We have the same workflow: run all tools in this toolbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# we need path to python toolbox
pyt_path = r"C:\path\to\toolbox\toolboxName.pyt"
arcpy.ImportToolbox(pyt_path, "myToolbox")
# get parameters (each tool takes a single parameter, the geodatabase path)
gdb_path = str(parameters[0].value)

# Run all tools
arcpy.AddMessage(dir(arcpy.myToolbox))
for t in dir(arcpy.myToolbox):
    # Skip the tools we do not want to run
    if t.startswith("_") or t.startswith("RunAll"):
        continue
    arcpy.AddMessage("Running {}".format(t))
    try:
        tool = getattr(arcpy.myToolbox, t)
        tool(gdb_path)
    except Exception as e:
        arcpy.AddError("{} failed...".format(t))
        arcpy.AddError(e)
        arcpy.AddError("-------------")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2024 20:00:25 GMT</pubDate>
    <dc:creator>uasdev</dc:creator>
    <dc:date>2024-10-29T20:00:25Z</dc:date>
    <item>
      <title>Imported toolbox runs very slowly</title>
      <link>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1550029#M73056</link>
      <description>&lt;P&gt;I successful import a custom toolbox. Inside the custom toolbox are multiple toolsets. The toolbox is "NWI_Toolbox", the toolset is "Combined Tools", and the tool is "Combined Wetland Polygonal Tools". This tool essentially runs all of the individual tools in a separate toolset named "Individual Polygonal Tools".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When I do this manually, the tool takes about &lt;STRONG&gt;40 seconds&lt;/STRONG&gt; to run. When I do it via Python, it imports successfully and then takes about&amp;nbsp;&lt;STRONG&gt;80 minutes&lt;/STRONG&gt;. What might explain this discrepancy?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Notice in the code below that I call the imported toolbox as "QC_Tools" - this is the alias of the toolbox. I have also tried importing the toolbox with a designated module name and calling it that way, but get the same result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;nwi_toolbox = r'C:\projects\Tools\Round1\NWI_Toolbox.pyt'

arcpy.ImportToolbox(nwi_toolbox)
arcpy.QC_Tools.combinedPolyTools(ak_schema_gdb, 'AK', 'DE', True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 16:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1550029#M73056</guid>
      <dc:creator>dale_elenteny</dc:creator>
      <dc:date>2024-10-18T16:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Imported toolbox runs very slowly</title>
      <link>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1550545#M73063</link>
      <description>&lt;P&gt;Is the slowdown spread across the execution of the tools? Or is it directly at the start of each tool's execution? It could be a repeated license check that the tool is running or some repeated initialization of the tool. I'd also try combining all the existing scripts into one tool to see if the slowdown still occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;80 Minutes is a massive slowdown though and it's hard to tell exactly what could be causing it without some test cases or logging info.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 17:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1550545#M73063</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-10-21T17:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Imported toolbox runs very slowly</title>
      <link>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1553493#M73109</link>
      <description>&lt;P&gt;The following code seems to work fine for me (speed wise when compared to manual runs).&lt;/P&gt;&lt;P&gt;We have the same workflow: run all tools in this toolbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# we need path to python toolbox
pyt_path = r"C:\path\to\toolbox\toolboxName.pyt"
arcpy.ImportToolbox(pyt_path, "myToolbox")
# get parameters (each tool takes a single parameter, the geodatabase path)
gdb_path = str(parameters[0].value)

# Run all tools
arcpy.AddMessage(dir(arcpy.myToolbox))
for t in dir(arcpy.myToolbox):
    # Skip the tools we do not want to run
    if t.startswith("_") or t.startswith("RunAll"):
        continue
    arcpy.AddMessage("Running {}".format(t))
    try:
        tool = getattr(arcpy.myToolbox, t)
        tool(gdb_path)
    except Exception as e:
        arcpy.AddError("{} failed...".format(t))
        arcpy.AddError(e)
        arcpy.AddError("-------------")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 20:00:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/imported-toolbox-runs-very-slowly/m-p/1553493#M73109</guid>
      <dc:creator>uasdev</dc:creator>
      <dc:date>2024-10-29T20:00:25Z</dc:date>
    </item>
  </channel>
</rss>

