AnsweredAssumed Answered

arcpy.AddMessage out of sequence on large process?

Question asked by compase@uww.edu on Dec 22, 2016
Latest reply on Jan 6, 2017 by compase@uww.edu

Anyone encountered the message queue getting out of sequence (at least in the Python toolbox results window) on a large process? I'm running a long Python process -- looping through ~300,000 rows -- and getting messages (used for debugging) that are clearly out of sequence. Or, I've completely lost sight of how Python loops work.

 

Any insights?

 

Eric

 

The message window (near the end of the process):

 

The Python loop:

# loop through all parcels
sql = "PropertyID IS NOT NULL"
with arcpy.da.UpdateCursor(parcel_fc,parcel_fields,sql) as cursor:
     i = 0
     for row in cursor:
          propertyID = row[0]
          sql = "PropertyID = "+str(propertyID)
          arcpy.AddMessage("SQL = "+sql)
          # select related records in deeds table, take only 1st result
          with arcpy.da.SearchCursor(deed_tbl,deed_fields,sql,sql_clause=("TOP 1","ORDER BY DeedDate DESC")) as cursor2:
               j = 0
               for row2 in cursor2:
                    arcpy.AddMessage("DeedID = "+str(row2[1])+", DeedDate = "+str(row2[2]))
                    row[1] = row2[1]
                    row[2] = row2[2]
                    row[3] = row2[3]
                    cursor.updateRow(row)
                    j += 1
               arcpy.AddMessage("Rows found = "+str(j))
               if j > 1:
                    arcpy.AddMessage("Found more than one deed")
                    sys.exit(0)
          i += 1
          #if i > 1000:
          #     arcpy.AddMessage("Rows updated ="+str(i))
          #     sys.exit(0)
     arcpy.AddMessage("Rows updated ="+str(i))
arcpy.AddMessage("AddLatestDeed.py finished")

Outcomes