In the past, I've successfully used arcpy.TestSchemaLock prior to undertaking schema modifications within script tools. I've recently upgraded to 10.5.1 and discovered that arcpy.TestSchemaLock is now returning False when it should return True.
The example snippet below returns False in the Python window, but I can immediately add a field to the tested feature class, which indicates that it is not locked and should have returned True.
Did something get broken in 10.5.1 that worked in 10.4.1?
>>> fc = r'C:\Workspace\2017_Hyde\incident_data\2017_Hyde_AzCof331_Events.gdb\EventLine
>>> canGetLock = arcpy.TestSchemaLock(fc)
Solved! Go to Solution.
I have the same problem in 10.5.0
Thinking which function would be used without modified the dataset. Currently I get AlterField_management.
import arcpy def isLocked(dataset): # if arcpy.TestSchemaLock(dataset): # return False # else: # return True try: arcpy.AlterField_management(dataset, "OBJECTID") return False except Exception as ex: return True