Can anyone spot an issue with the codeblock? I'm not exactly sure what occurred but this was working on Monday, I was out all-day Tuesday, and now Wednesday (today) the script fails to update, there are no errors and simply "hangs" and I must kill the PythonWin session.
The sde database that this Feature Class is in is for non-versioned editing.
ws = r'\\path_to_conn_file\my_conn_file.sde'
fcname = r'schema.FEATURE_CLASS_NAME'
input_fc = os.path.join(ws, fcname)
input_fc_sql = "APP_ID='" + inputAppId.strip().upper() + "'"
#check for a matching appId and set successmsg parameter for return JSON
test = [trow[0] for trow in arcpy.da.SearchCursor(input_fc, ['APP_ID'], input_fc_sql)]
if len(test) > 0:
##open edit session
edit = arcpy.da.Editor(ws)
edit.startEditing(False, False)
edit.startOperation()
with arcpy.da.UpdateCursor(input_fc, ['REVIEW_STATUS', 'PERMIT_ID', 'PERMIT_TYPE', 'PERMIT_SUBTYPE', 'PROJECT_NAME'], input_fc_sql) as ucur:
for urow in ucur:
urow[0] = inputStatus.strip().upper()
urow[1] = inputPermitId.strip().upper()
urow[2] = inputPermitType.strip().upper()
urow[3] = inputPermitSubType.strip().upper()
urow[4] = inputProjectName.strip().upper()
ucur.updateRow(urow) #seems to hang here and does not go to print statement below
print "step 1"
## Stop the edit operation.
edit.stopOperation()
## Stop the edit session and save the changes
edit.stopEditing(True)
Solved! Go to Solution.
The Feature Class is a source to a GP service and it needed to be stopped in order to run this script.
Sorry James, it's a bit obscure what this is doing
input_fc_sql = "APP_ID='" + inputAppId.strip().upper() + "'"
And where the other input... updates are coming from..
urow[0] = inputStatus.strip().upper()
urow[1] = inputPermitId.strip().upper()
urow[2] = inputPermitType.strip().upper()
urow[3] = inputPermitSubType.strip().upper()
urow[4] = inputProjectName.strip().upper()
What does test look like?
They're just input parameters. I could manually set these to some value and still get the same behavior.
However, the issue I was having was due to the fact that this is the source to a GP service and it needed to be stopped in order to run this script.
Thanks for your input
The Feature Class is a source to a GP service and it needed to be stopped in order to run this script.