We have an attribute domain that will need to be updated on a regular basis as new values are added to a master table of street names, and we are trying to find a way to script out the updating of it. Now the issue is this domain is assigned to fields in several feature classes that will almost always have schema locks on them from users leaving ArcMap documents open and some map services.
We have tried several versions of a workflow in our Python script; but it always ends up reporting the same error at some point:
ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application.
When our nightly update scripts run there will almost always be some schema locks on that domain; so we need to find a way to update the domain with those present if possible.
Wondering if anyone has run into a similar issue and found a workflow that gets around those pesky schema locks?
City of Auburn, AL
Did you ever get an answer? I'm running into the same issue here.
Venus, we haven't gotten any answer to this issue so far. We're still having to manually kill locks and update the domains as-needed.
Bummer. If I find out anything, I'll post it. Thanks.
Have you looked into blocking connections to your database then disconnecting all users? You would need SDE or DBO level rights on your geodatabase.
Your script would connect using SDE or DBO and that connection would remain active. However, you would ensure no additional locks by blocking connections and disconnecting all users:
import arcpy import time from arcpy import env # Connection to database (SDE User), set workspace database_conn = r'Database Connections\Enterprise.sde' env.workspace = database_conn # Block new connections to the database. try: print 'Blocking connections in %s' % database_conn arcpy.AcceptConnections(env.workspace, False) except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e: print e print 'Blocked all connections' # wait 60 seconds time.sleep(60) # Disconnect all users from the database. try: print 'Disconnecting all users from %s...' % database_conn arcpy.DisconnectUser(env.workspace, "ALL") except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e: print e print 'Disconnected all users' # RUN ADDITIONAL PROCESSING HERE # Allow the database to begin accepting connections again try: print 'Accepting Connections from %s...' % database_conn arcpy.AcceptConnections(env.workspace, True) except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e: print e