Select to view content in your preferred language

arcpro 2.6 arcpy fgdb lock files not clearing

3793
11
08-03-2020 12:53 PM
KennethSmith1
Emerging Contributor

I recently upgraded to Arcpro 2.6 and am having issues with an ArcPy script that exported data to a file geodatabase and then zipped that fgdb.

res=arcpy.FeatureClassToFeatureClass_conversion(in_features=inFeature, out_path=I10_fgdb, out_name=FC)
del res

 shutil.make_archive(fgdbPath, 'zip', ZipPath,fgdb)

This worked just fine in 2.5.X, however, after the upgrade, the lock file in the FGDB directory is not going away and that causes the zip to fail. How can I get ArcPy to clear the lockfile in a FGDB?

Thanks

11 Replies
DanPatterson
MVP Esteemed Contributor

If this worked in 2.5, I would report to Technical Support.

Arcpy can't clear locks... it is well requested item


... sort of retired...
0 Kudos
CooperLogan
Esri Contributor

Hi Kenneth Smith

It sounds like this issue has been reported as a bug with 2.6:

[ BUG-000133976: Unexpected behavior creating file geodatabases at 2.6 ]

Hope this helps!

Cooper

0 Kudos
DonMorrison1
Frequent Contributor

Hi Cooper - do you know if there is a way to circumvent this problem?  I have a number of critical scripts that are broken due this bug.  I'm willing to go in and add some code if necessary.  It looks to me like the only way to get rid of that lock file is to end the python script's process, but to do that in the middle of the script is really not feasible.

0 Kudos
DanPatterson
MVP Esteemed Contributor

BUG-000133976: Unexpected behavior occurs when creating file geodat.. 

no alternate solution provided


... sort of retired...
0 Kudos
CooperLogan
Esri Contributor

Hi Don,

One workaround that allowed some users to circumvent the problem is to add the following line right before the script errors out:

  • arcpy.ClearWorkspaceCache_management()

I hope this helps!

Cooper

Don Morrison

MarcoBoeringa
MVP Regular Contributor

Cooper Logan‌,

I am confused. This issue is about File Geodatabases being kept locked. The workaround you suggested shouldn't work according to this Help page, as arcpy.ClearWorkspaceCache_management() is only supposed to do anything for Enterprise Geodatabases, not File Geodatabases. The Help is quite adamant on that aspect:

"This tool only works with enterprise geodatabase workspaces."

0 Kudos
JustinKraemer
Emerging Contributor

@MarcoBoeringa, I saw your reply, but decided to give it a try anyway, and found it worked! Mine is a file geodatabase. Just thought I should share

0 Kudos
GavinMcGhie
Regular Contributor

I would add that I also used this solution to resolve a lock on an FGDB prior to trying to zip it with py.shutil and it resolved my issue as well even through it's an FGDB!

0 Kudos
MarcoBoeringa
MVP Regular Contributor

I also wonder if this issue is actually being worked on? This is a quite hideous issue, causing significant problems for arcpy / Python development. I have reported a similar issue to the Dutch branch of ESRI based on a custom arcpy Python geoprocessing tool of mine that suddenly started failing going from Pro 2.4.3 to Pro 2.5, and the issue was also caused by left over *.lock files in a File Geodatabase folder, that weren't being cleaned up in Pro 2.5, while not an issue and being cleared properly in Pro 2.4.3.

It is registered as:

BUG-000131154 Fgdb locking behavior is different in ArcGIS Pro 2.5 to ArcGIS Pro 2.4.3 for copying styles

0 Kudos