Have an issue with Geoprocessing service while doing start editing for more than one user at same time.
Input for Geoprocessing service is CAD drawing file(dgn/dwg) from web application. and Geoprocessing code is inserting the features to appropriate feature classes in enterprise geodatabase.
Enterprise geodatabase is versioned and editing is doing in SDE.Default. ArcGIS server version is 10.8
Please find the code snippets
eGeoDBWorkSpace = r"dbconnection.sde" #Enterprice geodatbase
----
edit = arcpy.da.Editor(eGeoDBWorkSpace)
try:
edit.startEditing(True, True) -- *Error
edit.startOperation()
inserCursor = arcpy.da.InsertCursor(polyFC,['ID',...., 'SHAPE@'])
for inRow in poly_insert_rows:
inserCursor.insertRow(inRow)
del inserCursor
arcpy.AddMessage("MP to Temp FC finished")
inserCursor = arcpy.da.InsertCursor(plynFC,['ID',...., 'SHAPE@')
for inRow in plyn_boundary_insert_rows:
inserCursor.insertRow(inRow)
del inserCursor
-------
-----
edit.stopOperation()
edit.stopEditing(True)
except Exception as err:
#arcpy.AddError(err)
if 'edit' in locals():
if edit.isEditing:
edit.stopOperation()
edit.stopEditing(False)
*Error : Getting error on this line , If editing started by one user request, between any other request came to the server.The new request will fail.
Really appreciate the support to resolve this issue.
Solved! Go to Solution.
I have run into a similar issue when trying to editing using an .sde.
Are you getting an error like this "The version has been redefined to reference a new database state"?
A solution is to edit a feature service instead? Publish the CAD drawing as a branched versioned dataset and edit that. You won't have to use edit.startEditing, edit.startOperation() workflow because the database editing will be taken care of by the ArcGIS Software.
could you format your code to facilitate syntax errors
Code formatting ... the Community Version - Esri Community
//Start
eGeoDBWorkSpace = r"dbconnection.sde" #database connection
----
-----
edit = arcpy.da.Editor(eGeoDBWorkSpace)
try:
edit.startEditing(True, True) #*Error : Getting error on this line , If editing started by one user request, between any other request came to the server.The new request will fail.
edit.startOperation()
inserCursor = arcpy.da.InsertCursor(polyFC,['ID',...., 'SHAPE@'])
for inRow in poly_insert_rows:
inserCursor.insertRow(inRow)
del inserCursor
arcpy.AddMessage("MP to Temp FC finished")
inserCursor = arcpy.da.InsertCursor(plynFC,['ID',...., 'SHAPE@')
for inRow in plyn_boundary_insert_rows:
inserCursor.insertRow(inRow)
del inserCursor
-------
-----
edit.stopOperation()
edit.stopEditing(True)
except Exception as err:
if 'edit' in locals():
if edit.isEditing:
edit.stopOperation()
edit.stopEditing(False)
------
------
arcpy.ClearWorkspaceCache_management()
//End
I suspect you are using a connection file to connect to your Enterprise Geodatabase. You need to give the complete path to that connection file. I use a connection file this way in python:
ws = r'\\complete path\to my\connection file\ConnectionFileName.sde'
edit = ws
Hi JoeBorgione,
I am providing complete shared path. While doing the post I just modified the path. FYI,Code is working fine with single request at a time. Only problem is when there is concurrent users trying to edit the feature class.
Is the data versioned?
Yes.It is versioned.I am editing in sde.default itself
I have run into a similar issue when trying to editing using an .sde.
Are you getting an error like this "The version has been redefined to reference a new database state"?
A solution is to edit a feature service instead? Publish the CAD drawing as a branched versioned dataset and edit that. You won't have to use edit.startEditing, edit.startOperation() workflow because the database editing will be taken care of by the ArcGIS Software.
Hi DavinWalker2,
Yes. While running in desktop I am getting the same error message you have mentioned. But once I published as the geoprocessing service I am getting exception message as "error return without exception set"(If there is concurrent requests).
Would like to know few more details about your solution.
Please note that we are consuming this geoprocessing from ArcGIS JS API application. To immediately show the drawing file geometries over the base map with appropriate layer name and symbology.
A solution is to edit a feature service instead? - Yes, I'm suggesting to use a feature service. You could just use the arcpy.da.InsertCursor and each row would be inserted independently.
Branched versioned dataset? - Sorry disregard if you do not have ArcPro and Portal.
Does this mean that concurrent editing is not possible using arcpy.da.Editor in geoprocessing? - I have not been able to get it to work correctly. this post also mentions the same or similar issue https://community.esri.com/t5/python-questions/multi-user-editing-in-arcpy/td-p/41607
I hope you can figure out a workflow that best suits your requirements from the information I have provided.