HOW TO
In ArcGIS Pro, when using the Named User license, the license token expires every 15 days, which affects the Python scripts or tasks fail to run once the token expires. For more information, refer to ArcGIS Developers: Request parameters. To avoid this, the Named User license must be refreshed by manually launching ArcGIS Pro before the token expires.
This article demonstrates the workflow to automate the ArcGIS Pro launch and shutdown to refresh the license token during a Python task automation.
Note: Before automating Python scripts or tasks with ArcPy, ensure there is valid access to the ArcGIS Pro license by signing in with a licensed account or using a license file.
Note: The indentations must be maintained in the script.
#!/usr/bin/python # -*- coding: utf-8 -*- import subprocess, time, threading
timer:int=25
arcgispro = None
def counter_(): print("ArcGIS Pro Opening...") for i in range(timer - 1, 0, -1): time.sleep(1) print(i)
def openArcGISPro_reset(): try: global arcgispro arcgispro = \ subprocess.Popen([r"C:\Users\<username>\AppData\Local\Programs\ArcGIS\Pro\bin\ArcGISPro.exe"]) time.sleep(timer) arcgispro.terminate() except Exception as e: print(e)
threading.Thread(target=counter_).start()
Note: Once the countdown reaches 1, press Enter.
openArcGISPro_reset()
The code block below demonstrates the full working script.
#!/usr/bin/python # -*- coding: utf-8 -*- import subprocess, time, threading timer:int=25 arcgispro=None def counter_(): print("ArcGIS Pro Opening...") for i in range(timer - 1, 0, -1): time.sleep(1) print(i) def openArcGISPro_reset(): try: global arcgispro arcgispro = \ subprocess.Popen([r"C:\Users\<username>\AppData\Local\Programs\ArcGIS\Pro\bin\ArcGISPro.exe"]) time.sleep(timer) arcgispro.terminate() except Exception as e: print(e) threading.Thread(target=counter_).start() openArcGISPro_reset()
The image below shows ArcGIS Pro automatically resetting after running the script.
Get help from ArcGIS experts
Download the Esri Support App