2

I have not yet pulled this down to a code snippet that has just enough in it to reproduce the error below that I am getting when I run my code in IDLE.

pythonw.exe has stopped working
Windows is checking for a solution to the problem

enter image description here

However, I am seeing it when my script repeatedly runs Trace Geometric Network which I am doing to try and identify isolation valves for almost 1,000 locations on a water network.

These are a few lines from the code:

        print_message("Trying to trace")
        arcpy.TraceGeometricNetwork_management(
            r"C:\Users\101791\test.gdb\WaterNetwork\WaterNetwork",
            r"in_memory\WaterDistribution_Net",
            r"C:\Users\101791\test.gdb\Flag",
            "FIND_CONNECTED", "", "", "", "", "wSystemValve",
            "TRACE_ENDS", "", "", "", "AS_IS", "", "", "", "AS_IS")
        print_message("Traced OK")

and this is the ouput I get. The error in the image above occurs after it has run Trace Geometric Network eight times successfully immediately after printing "Trying to trace" the ninth time.

1
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV71818']
2
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV71818']
3
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV130266']
4
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV12053', u'RV415348']
5
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV12052', u'RV12051']
6
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV12060', u'RV12059']
7
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'RV12060', u'RV12061']
8
2074
Trying to trace
Traced OK
Isolation Valves for KCA 2074: [u'WSF405337']
9
2086
Trying to trace

If I try to start the process on the ninth flag pythonw.exe stops immediately. If I set my code to skip trying the 9-10th and 12-14th flags then all the others work until it gets to the 28th. The first failure occurs when the KCA value changes for the first time, but the 11th flag (which works) has the same KCA value of 2091 as the 12th-14th (which work) so particular KCA values do not appear to be the cause.

Does anyone have any thoughts on how I may be able to troubleshoot this?

I have a suspicion there may be some interplay between how much memory is needed to perform a geometric network trace and the way the Trace Geometric Network tool writes its result as an in_memory group layer.

I am using ArcGIS Desktop 10.2.1.01 on Windows 7 SP1.

closed as off-topic by PolyGeo Feb 10 at 23:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Monitor the python process to verify if it is running out of memory. Are you able to execute the failing traces manually? Write results to disc. Try using 64 bit processing. Architect the script to use subprocess to trace in case of memory issues your main thread will continue. – Ben S Nadler Nov 6 '17 at 12:08
  • @BenSNadler I think your comment would make a useful answer, even if it is only "Some things to try are: " and half a dozen dot points. The one that I would like to learn more about is how to "Architect the script to use subprocess to trace". I often see subprocess mentioned but have never used it. – PolyGeo Nov 8 '17 at 0:47
  • I found How To: Run multiple Python scripts from a single parent script. that shows me how to use subprocess to do what I need when I get back onsite (probably tomorrow). – PolyGeo Nov 8 '17 at 1:30
  • I would first confirm you are running out of memory and maybe try to mitigate that per the recommendations. It is easier to do that then multithread. I found using subprocess or multithreading (different options, more than semantics ) to be a bit tricky and a departure from the usual scripting structure but as you found there are plenty of examples. – Ben S Nadler Nov 9 '17 at 6:05
  • @BenSNadler Using Task Manager the memory usage seems to go no higher than about 50-60%. I've used subprocess to isolate each run of the trace to its own subprocess and that is running well except that when the trace fails it leaves a dialog box up that still needs to be clicked away before the process continues. It's about 1 in 10-15 traces that give this failure, always on the same flag locations. – PolyGeo Nov 9 '17 at 6:47