ArcGIS Project (.aprx) lock not released

1305
7
09-19-2018 12:26 AM
nita14
by
Regular Contributor

Dear All,

It seems that arcpy.mp does not release the lock of the resulting (new) aprx document. The following code does create a new aprx file:

aprx_project.saveACopy(os.path.join(workspace, prefix, name_to_save))
del aprx_project

Unfortunately, the lock persists on the new .aprx file. Is there any way to remove it? Only after I close the ArcGIS Pro which I use to run the script, the lock is released.

Any hints are much appreciated!

Adam


ArcGIS Pro v.2.2.2

Tags (1)
7 Replies
DanPatterson_Retired
MVP Esteemed Contributor
# ---- try the hardway
aprx_project.saveACopy(os.path.join(workspace, prefix, name_to_save))

workspace = None
prefix = None
name_to_save = None

del prefix
del workspace
del name_to_save
del aprx_project

#---- still may fail to release the lock

#----  close your ide

are you running this in the internal python ide or an external one?

I suppose you have tried deleting the workspace, prefix and name_to_save prior to deleting the project variable as well.

finally, try closing the python window.  'del' removes the variable from the namespace only, locks can be  different beast

nita14
by
Regular Contributor

Dear Dan.

I am running the script from ArcGIS Pro (Script tool in Toolbox), so there is no python window or ide to close.

Indeed, I tried to delete those variables as well.

The documentation clearly states that the object still has the reference to the former aprx file:

The method creates a new output project file, but the project variable continues to reference the original ArcGISProject object. It does not duplicate all the content within a project folder.

So, I reckon it is a bug in arcpy....

Best Regards!

Adam

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

When you run it from the tool in arctoolbox and it completes, do you notice an orange exclamation mark beside the output filename, with a warning that the output filename already exists?  If so, this would mean that references to the output filename persist.  If not, then the deletion of the output filename is no longer in memory..  Worth a check

0 Kudos
nita14
by
Regular Contributor

No warnings at all in the tool output window...

It seems that I need to get use to that :)

Adam

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

This is what you get, until the tool is closed, 

0 Kudos
nita14
by
Regular Contributor

Dear Dan,

The name is unique. No warnings at all.

Adam

0 Kudos
DonMorrison1
Occasional Contributor III

I've run into the same problem - very simple scenario and there seems to be nothing I can do in my python script to delete the aprx file that I've finished with.  Restarting the python process gets rid of the file but that isn't really an option in my workflow.

0 Kudos