Select to view content in your preferred language

Multi-user editing in ArcPy

3024
7
02-01-2017 02:44 PM
MarkTurnbull
Regular Contributor

I have a python script that updates attributes on a versioned feature class from an external table. It uses the arcpy.da.editing functions (startediting, startoperation, updatecursor, stopoperation, stopediting). The script does not create any named versions.  It works fine if one person uses it. If a second person runs it at the same time as the first, the second person gets the following error message

Traceback (most recent call last):
File "C:\Users\ArcG_adm\AppData\Local\ESRI\Desktop10.4\AssemblyCache\{89912E36-0BFE-45B9-8E7D-84A455D7E3A1}\MCWEditingTools_addin.py", line 724, in executeSelectedFeatures
editor.stopEditing(True)
RuntimeError: The version has been redefined to reference a new database state. [sde.DEFAULT]

So it appears as though it cannot reconcile. Has anyone come across this before? Am I doing something wrong or missing a step?

Tags (3)
0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/editor.htm

a couple of issues are flagged

Deviating from this pattern can cause unexpected results. For example, stopEditing should not be called while an edit operation is in progress. Instead, abort the edit operation and stop the edit session.

Cursors should be scoped to a single edit operation. This means a new cursor should be instantiated and released for each operation. This is very important when editing rows returned by a cursor because the rows are tied to a specific state of the geodatabase. Avoid using a cursor across multiple edit operations. Doing so can result in unexpected

I am surprised this can be done with multiusers... they don't give any examples of this in the help topic... like how do you shuffle the combinations of starting, stopping etc between individuals?

MarkTurnbull
Regular Contributor

Thanks for your response Dan. I can confirm that my operation is stopped before I stop editing and I even made sure that only one update cursor occurred with a single operation, but still no luck.

0 Kudos
DanPatterson_Retired
MVP Emeritus

You will have to seek guidance internally within esri I suspect

0 Kudos
MichaelMorisette
Occasional Contributor

I have a very similar issue to this.  I have an ArcPy script that calculates some fields in a versioned feature class.  It works fine unless one of our users has saved an edit within the time-frame of when the script runs (which is a very likely occurrence during work hours)!

Traceback (most recent call last):
  File "\\xxx\Scheduled Tasks\lib\CalculateFMAFFields.py", line 394, in <module>
    edit.stopEditing(True)
RuntimeError: The version has been redefined to reference a new database state. [dbo.DEFAULT]

I figure this is "by design," but there must be a workaround.  Is there something I can set in the workspace and/or editing environment in Python to override this behavior?  I'm thinking this is equivalent to how I get the set the option to "Automatically save changes only if there are no conflicts" in my ArcMap editing settings so that I don't get that annoying popup every time I save edits there.

Thanks

MichaelMorisette
Occasional Contributor

Does anybody know of a way to override the state change check in arcpy?  I looked at attributes arcpy.da.Editor as well as arcpy.env and have come up blank.

It's frustrating to have to continually re-run a script until I happen to hit the lucky moment when none of our users have saved an edit recently.

0 Kudos
RussellProvost1
Occasional Contributor

Any solution to this issue? I am trying to save a versioned (default) feature class via python and running into the same issue. 

0 Kudos
MickaëlDe_Preester1
Emerging Contributor

Hi Mark and Michael,

I'm facing the same issue.

Did you figure it out?

Thanks

0 Kudos