I have a script that checks the status of some key services we have to make sure that they are "STARTED". If the status is something other that "STARTED" an email goes out to notify me. It is scheduled to run on a regular basis and for the most part it works great.
Some of the time the script will take much longer to run (15 to 20 minutes) than the usual 10 seconds or so. I logged timestamps within the script and saw that the problem is where I try to list the services within a specified folder on a specified server. When this line works normally it takes 1 second but sometimes it can stall on this step for many minutes.
gisServices = gisServer.services.list(folder=folderName)
Has anyone else experienced delays in their scripts when using the list() method? I suspect this has something to do with my enterprise being highly available (Portal with Primary and Standby servers, and 3 federated ArcGIS Server Sites that have 2 servers each).
Another odd part of this is that when the script stalls for a long enough time, the script will be launched again by the task scheduler. The script that launched after the first script seems to "unclog" or "jump start" the first script and both scripts will finish within the next few seconds.
I have several other scripts that use the list() method and they suffer similar issues where it will have a lengthy stall some of the time.
That's a challenging problem because it doesn't seem like the list() function has any print statements you can use for debugging... yet. You could step through it using your IDE and add various print statements in the function so you know where it's hanging. What URL are you using to connect to the site? You can experiment with different ones to see if it's a specific machine that's a problem.