Cannot delete version created with python tool

6520
13
02-19-2015 11:41 AM
MatthewLueders
New Contributor

I am having an issue where I cannot delete a version because it is said to still be in use, but this error only arises when I use the script from an ArcGIS Tool in the Toolbox.  When I run the script from an outside IDE, or even the same commands from the python window, it finishes without error.

The general process is:

1) create a new version "Child"

2) Loop of feature classes:

    2.1) create feature layer

    2.2) change to version "Child"

    2.3) various queries etc

    2.4) copy feature layer

    2.5) change to version Default

3) run arcpy.ClearWorkspaceCache_management()  [updated]

4) delete version "Child" --- arcpy.DeleteVersion_management(sde_database, "username".Child)

The error returned by the tool dialogue is:

Executing: DeleteVersion "/path/connectionfile.sde" "username".Child

Start Time: Thu Feb 19 13:12:24 2015

ERROR 999999: Error executing function.

The version is currently in use. ["username".Child]

Failed to execute (DeleteVersion).

At this point I will go to the Version Manager to delete the Child version manually and I get the following error:

Could not delete version "username".Child.

[An event was unable to invoke any of the subscribers (Exception from

HResult: 0x80040201)]

If I close and reopen ArcMap I can then delete the version. Does anyone have an idea what might be causing this and how to resolve it?

0 Kudos
13 Replies
MatthewLueders
New Contributor

It's a public version.  I just can't connect to it from a stand-alone script.  That's another approach to resolving this, I guess, if I didn't need the additional version.  I just haven't been able to find a way to connect to that version directly. Specifying the other "Username.version" doesn't work.

0 Kudos
MatthewLueders
New Contributor

I missed one of your questions:

Oh, so the version you make is created under another version that has changes you want to see?

Yes

Were you using arcpy.ChangeVersion_management() to change versions?

Yes

Can the changes in the parent version be posted up so you can just do the script work on Default?

No

0 Kudos
MatthewLueders
New Contributor

Reconciling didn't seem to help.  Good thought though.

0 Kudos
MattFrancis
New Contributor III

I am stuck in the same spot.  Did you figure out what was holding the connection open?

0 Kudos