Python arcpy 更新游标循环中断

Python arcpy update cursor loop interrupted

制作此脚本是为了清除 table 行,而在另一个 table 中没有对应的行(必须通过 arcpy 制作,因为 table 是一项功能 class 启用存档,来自 ESRI)。我正在生产中测试这个脚本,所以,我只是使用一个计数器,而不是实际擦除行。但是,当计数器 'excluidos' 的值约为 310000 时,脚本就会停止。 arcpy 更新游标有内存限制吗? (通常我会收到一些 python 内存错误消息,但这里不是这种情况)或者这里有一些我遗漏的逻辑问题?

# -*- encoding: utf-8 -*-
import os.path, sys, time
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from arcpy import da

pasta = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'modelos'))

fc = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.fis_vistorias_aia_tcra'
fc2 = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.tb_fis_vistorias_aia_tcra'
workspace = os.path.dirname(fc)

campos = [
    "NIS"
    ,"Sigla"]

campos2 = ["NIS", "DataElabRTV"]

print str(time.strftime('%x %X'))
print 'Iniciando busca de registros no workspace: ' + fc2

lista = []
listIg = []

with da.SearchCursor(fc2, (campos2)) as sc:
    for row in sc:
        if row[0] <> None:
            lista.append(row[0])

print str(time.strftime('%x %X'))
print 'Iniciando exclusao de registros no workspace: ' + fc

try:
    edit = da.Editor(workspace)
    print str(time.strftime('%x %X'))
    print 'Iniciando edicao.'
    edit.startEditing(False, False) #undo/multiuser
    print str(time.strftime('%x %X'))
    print 'Iniciando operacao.'
    edit.startOperation()
except Exception as e:
    print e
    sys.exit(0)

print str(time.strftime('%x %X'))
print 'Iniciando exclusao.'
excluidos = 0
ignorados = 0
multiplo = 100000
try:
    with da.UpdateCursor(fc, (campos)) as cursorExc:
        for row in cursorExc:
            if row[0] <> None:
                verifExcec = False
                for reg in lista:
                    if reg == int(row[0]):
                        verifExcec = True
                if verifExcec:
                    listIg.append(reg)
                    ignorados += 1
                    continue
                else:
                    #cursorExc.deleteRow()
                    excluidos += 1
            else:
                ignorados += 1
            #verifica se o contador e igual ao multiplo definido para emitir o aviso
            if (excluidos % multiplo == 0):
                print u"{0} - {1} ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."


except Exception as e:
    print e

print str(time.strftime('%x %X'))
print str(excluidos) + ' registros excluidos.'

print str(time.strftime('%x %X'))
print str(ignorados) + ' registros ignorados.'

try:          
    # Stop the edit operation.
    print str(time.strftime('%x %X'))
    print 'Encerrando operacao.'
    edit.stopOperation()

    # Stop the edit session and save the changes
    print str(time.strftime('%x %X'))
    print 'Encerrando edicao.'
    edit.stopEditing(True)
except Exception as e:
    print e

listIg.sort()
for nis in listIg:
    print nis

我认为限制是在 arcpy 上,所以我应该在 GIS Stack Exchange 上提出问题。无论如何,我 'resolved' 这个问题有一个更慢的解决方案,为每个排除启动和停止版本:

print str(time.strftime('%x %X'))
print 'Iniciando busca de registros no workspace: ' + fc2

listAIA = []
listVist = []
listIg = []
adicionados = 0
ignorados = 0

with da.SearchCursor(fc2, (campos2)) as sc:
    for row in sc:
        if row[0] <> None:
            listVist.append(row[0])

with da.SearchCursor(fc, (campos)) as sc1:
    for row in sc1:
        verifExcec = False
        if row[0] <> None:
            for vist in listVist:
                if int(row[0]) == vist:
                    verifExcec = True
            if verifExcec:
                ignorados += 1
                listIg.append(row[0])
                continue
            else:
                listAIA.append(row[0])
                adicionados += 1
        else:
            ignorados += 1
            listIg.append(row[0])

print str(time.strftime('%x %X'))
print 'Iniciando exclusao de registros no workspace: ' + fc

col_1 = 'NIS'
excluidos = 0
multiplo = 100000

for reg in listAIA:  
    expressao = '"' + col_1 + '" = ' + str(reg)
    try:
        edit = da.Editor(workspace)
        edit.startEditing(False, False) #undo/multiuser
        edit.startOperation()
    except Exception as e:
        print e
        sys.exit(0)

    try:
        with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
            for row in cursorExc:
                #cursorExc.deleteRow()
                excluidos += 1
                print u"{0} - {1} ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

    except Exception as e:
        print e   

    try:          
        # Stop the edit operation.
        edit.stopOperation()    
        # Stop the edit session and save the changes
        edit.stopEditing(True)
    except Exception as e:
        print e

    if (excluidos % multiplo == 0):
        print u"{0} - {1} ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

print str(time.strftime('%x %X'))
print str(excluidos) + ' registros excluidos.'

print str(time.strftime('%x %X'))
print str(ignorados) + ' registros ignorados.'