I am trying to let a user cancel the ArcToolbox script tool that I am creating. When the code is running, if I press cancel, the process just continues. I have looked at ESRI help on the issue (http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/understanding-cancellation-behavior-in-script-tools.htm) but I cannot get the tool to respond to the cancel command mid run.
I have tried both autoCancelling = true and false with various states of isCancelled both in and out of if statements.
What am I missing?
ArcpMap 10.3 python2.7
This is my attempt to date:
import arcpy, time from arcpy import env arcpy.env.autoCancelling = False if x == 1: arcpy.AddError('A landbase with this name already exists, you have 10s to cancel otherwise it will be overwritted') timing = 1 while timing < 11: time.sleep(1) arcpy.AddMessage(str(timing)) timing += 1 if arcpy.env.isCancelled == True: sys.exit()