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 sde_editor.stopEditing(False) del sde_editor if __name__ == '__main__': main() # still have locks here