Release lock on file geodatabase so it can be deleted in a python script?

2071
2
Jump to solution
08-02-2021 01:17 PM
Labels (2)
MaryroseKulick
New Contributor II

Hello! I am working on a script that will archive layers from AGOL in a zipped geodatabase. When I get to the clean up section, the script fails, because it can't delete a geodatabase with a lock in it. The lock is created during the script processes, so it's not being used by another user. Is there a way to release the lock in the same script? Here's my general workflow:

1. Log in to AGOL

2. Create a geodatabase

3. Copy layers from AGOL to the geodatabase

4. Zip the geodatabase

5. Delete the unzipped geodatabase (script fails here due to lock)

I'm very new to python, fyi. 🙂 Any help is appreciated!

0 Kudos
1 Solution

Accepted Solutions
MaryroseKulick
New Contributor II

Update, I fixed the problem by using arpy.management.Delete() instead of  os.remove()

Thanks for the input!

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

The lock will not be released until the script is done.  You can use arcpy.env.overwriteOut = True to simply overwrite the existing gdb's namespace the next time the script is run.  Sometimes a bit of fluff lies around if you don't want to delete things manually or in a separate script


... sort of retired...
0 Kudos
MaryroseKulick
New Contributor II

Update, I fixed the problem by using arpy.management.Delete() instead of  os.remove()

Thanks for the input!

0 Kudos