Hello, I am running ArcGIS 10.1 using file geodatabases. In order to update information across geodatabases I run a model that copies the information to each, unless the data is in use, causing a schema lock. If I were to convert my model into a python script, is there any way to have it display the users computer name that is causing the schema lock?
Solved! Go to Solution.
I don't believe there is an out-of-the-box way to do this if you're not using an enterprise geodatabase. If you wanted to get an idea of what machine may have created the lock I'd think that you can use pure python to list out the *.lock files that appear in the geodatabase. From this file you should be able to parse out the machine accessing the content within the geodatabase. For example, I tried this out on my machine and I can see that there are lock files with the following names.
_gdb.UZUMAKI.10792.10812.SR.lock
In the above case UZUMAKI is the hostname for my machine that is accessing the data. If needed you could use the following class to check if you're able to get an exclusive lock on the data.
TestSchemaLock
http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/testschemalock.htm
never had the need to use, nor tried, nor know if it will work in an Arc* environment, but the Stack Overflow choices seem to be ... Getting name of windows computer running python script? - Stack Overflow
I don't believe there is an out-of-the-box way to do this if you're not using an enterprise geodatabase. If you wanted to get an idea of what machine may have created the lock I'd think that you can use pure python to list out the *.lock files that appear in the geodatabase. From this file you should be able to parse out the machine accessing the content within the geodatabase. For example, I tried this out on my machine and I can see that there are lock files with the following names.
_gdb.UZUMAKI.10792.10812.SR.lock
In the above case UZUMAKI is the hostname for my machine that is accessing the data. If needed you could use the following class to check if you're able to get an exclusive lock on the data.
TestSchemaLock
http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/testschemalock.htm
Thank you very much for your reply. Would you have an example script that would produce a list of *.lock files for a particular geodatabase?
There will be quite a few ways to do this. I've listed a couple of the more popular options below. Each of these pages will provide examples on how to use the method.
Python os.listdir() Method
http://www.tutorialspoint.com/python/os_listdir.htm
glob - Filename pattern matching
Working with Directories
http://www.diveintopython.net/file_handling/os_module.html
List Files (arcpy)
http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfiles.htm