Is it possible to use arcpy.da.Editor and have it release its SDE locks in the same process?

I am using arcpy and trying to perform edit operations on an SDE version, then reconcile/post/delete the version in the same process. I get an error when deleting the version (trying both in ReconcileVersions and a separate DeleteVersion call), however, stating that the version is locked by a database user.

Querying sde.SDE_table_locks while stepping through the code shows that the locks are taken out in the startEditing call. After that call, the only way I can get the locks to release is when the process exits. Testing out an alternate method of making the updates in a separate process (using multiprocessing.Process) did allow the version to be deleted in the main process, but I would prefer to not have to do this.

Below is a sample that reproduces the locking behavior. We are using ArcGIS 10.2.1 build 3602, ArcSDE 10.2.1 release 102003, and SQL Server 2014.

import arceditor
import arcpy

def main():
    sde_connection = r'p:\ath\to\version_connection.sde'
    sde_editor = arcpy.da.Editor(sde_connection)
    # querying sde.SDE_table_locks, no locks exist
    sde_editor.startEditing(False, True)
    # locks now exist
    del sde_editor

if __name__ == '__main__':
    # still have locks here
  • What happens if you do your edition within a context manager (i.e. using the with statement)? – Marcelo Villa-Piñeros May 31 '19 at 22:27
  • ArcGIS 10.2 is a month from retirement, and 10.2.1 wasn't the final supported 10.2.x release, so you're working from a bad starting position. This is probably a conversation you need to have with Tech Support. – Vince May 31 '19 at 22:31
  • Using a context manager I get the error: 'Workspace Operation object' object has no attribute 'startEditing'. Regarding the version, we are on the Utilities and Telecom patches. I was under the impression these are supported for another year or so, but I can't find any documentation on that, so maybe not? – Trent May 31 '19 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.