Select to view content in your preferred language

arcpy.TestSchemaLock misbehaving at 10.5.1?

1225
7
Jump to solution
12-11-2017 02:58 PM
CarlBeyerhelm1
Occasional Contributor

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?

Thank you.

>>> fc = r'C:\Workspace\2017_Hyde\incident_data\2017_Hyde_AzCof331_Events.gdb\EventLine

>>> canGetLock = arcpy.TestSchemaLock(fc)
>>> canGetLock
False

0 Kudos
1 Solution

Accepted Solutions
7 Replies
DanPatterson_Retired
MVP Emeritus
CarlBeyerhelm1
Occasional Contributor

Thanks.  Could you re-try posting your link, please?  I'm getting a "This bug does not exist" page.

0 Kudos
DanPatterson_Retired
MVP Emeritus

http://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEwNDI4NQ== strange Jive seems to want to drop the ==

so just in case

0 Kudos
CarlBeyerhelm1
Occasional Contributor

OK, thanks.

I guess the workaround is to bracket schema lock-prone code with try: and except:

0 Kudos
MemoryBlue
Emerging Contributor

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‍‍‍‍‍‍‍‍‍‍
WayneBoras
Regular Contributor

This is a perfect workaround. Thank you!

0 Kudos
CarlBeyerhelm1
Occasional Contributor

For info...

I'm in Windows 10 now (was in Win7 previously), and arcpy.TestSchemaLock() now seems to be working in 10.5.1.

0 Kudos