Select to view content in your preferred language

Python Toolbox Slow to Load / Hangs

85
1
Wednesday
dslamb2022
Occasional Contributor

I have several large custom Python Toolboxes (multiple tools, several python files imported, 1000 lines in the pyt files) developed for ArcGIS Pro. Typically the tools are stored in a local folder and not on a network directory (although often they are in a local git repository to sync with updates). When a user adds them to a new ArcGIS Pro Project for the first time it will hang ArcGIS Pro until I/they use Task Manager to kill the process.

This can happen in different ways. When I use Add Toolbox in the catalog pane, it will not even show the toolbox and locks ArcGIS. If I navigate to the toolbox in the connected folders, it will show a spinner when I expand the folder and hang. When I open the project and readd, or navigate then it seems to work. Although, it may take several tries to get the tool added.

I don't remember having these problems with Python Toolboxes before version 3, and maybe up to 3.2. I've tried these on 3.3, 3.4, and 3.5. Multiple users have tried with similar issues on multiple versions and multiple computers. We share the same code and the same xml files associated with the pyt file (I thought maybe it was trying to recreate the xml files).

The tools work fine when the toolbox finally loads. And once they are loaded into the project, the issues don't return. 

1. What are some of the possible issues? Or is this just expected with toolboxes that have multiple files associated as it imports the modules.

2. Is there a way to "compile" so that it loads faster? 

0 Kudos
1 Reply
dslamb2022
Occasional Contributor

It seems to be a problem relating to importing other modules. Offloading all the importing except for what is needed to load the toolbox, and importing at execution seems to reduce the time to add the toolbox.

 

But, I'd like to hear other solutions.

0 Kudos