More often than not, python seems to be locking up my aprx after executing scripts. Opening ArcGIS Pro following script execution results in a schema lock. My script deletes the aprx as recommended but is there something else I need to do. Typically, I have not been saving the aprx so the aprx.save() is usually omitted. The scripts are ran outside of ArcGIS Pro in a standalone Jupyter Notebook environment.
The following snippet is recommended in the documentation:
aprx = arcpy.mp.ArcGISProject(<PATH>) mp = aprx.listMaps(<MAP NAME>) <DO SOMETHING> aprx.save() del aprx
I'm wondering if the following context manager would work better, but am not seeing anything in the documentation.
with arcpy.mp.ArcGISProject(<PATH>) as aprx: mp = aprx.listMaps(<MAP NAME>) <DO SOMETHING> aprx.save()
If you close your notebook, does the lock go away?
If you tried the "with" context manager approach, did you notice any difference?
I suspect it may be the "do something" section the persists the lock
After some more experimenting, it seems the del aprx doesn't fully release the lock, however, once the python kernel is stopped the lock is released. So, I'm getting into the habit of stopping or restarting the kernel should I need to run a series of scripts or GUI operations.