AnsweredAssumed Answered

RuntimeError: workspace already in transaction mode?! Help, pls!

Question asked by joanna.grossman on Apr 18, 2017
Latest reply on Apr 25, 2018 by adel407

Hi all -

I keep getting:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 26, in <module>
RuntimeError: workspace already in transaction mode

when I run my script. I can't sort out why.

Here's my code. (Not loving how the formatting works here.)

# Move points based up current lat/lon
#grab stuff you need
import arcpy
import os
print "Imported Libraries."

# Set variablesfilepath = r'S:\AGR\AGR-Shared\AGR-GIS\AGR_Data\Connection to cloud.agriculture.vermont.gov.sde'
fc = "AGRGISDATA.DBO.ApiariesWGS"
fc_path = os.path.join(filepath, fc)
fields = ['Longtitude','Latitude','SHAPE@XY']
#arcpy.env.workspace = fc_path #I don't think this is needed.
workspace = os.path.dirname(fc_path)
editor = arcpy.da.Editor(workspace) #this one throws "RuntimeError: workspace already in transaction mode"
print "Set vars."

editor.startEditing(False, True)
editor.startOperation()
print "Editor Commands."

#create curser on fc
#try:   
#print "Trying"
with arcpy.da.UpdateCursor(fc_path,fields) as cursor:   
print "With"   
for row in cursor:       
print "for row in cursor"       
x = row[0]       
y = row[1]       
xy = (x,y)       
pnt = xy       
row[2] = pnt       
cursor.updateRow(row)       
print "Updated Rows."
#finally:   
editor.stopOperation()   
editor.stopEditing(True)   
del editor
print "It worked!"

My code is indented properly, I just couldn't make it do so with the syntax highlighter here. I'm sure there's a way, but I haven't figured it out.

 

Anyway, I've been trying different things to get this code running again, and I'm out of ideas. Would love some help.

Thx

JG

Outcomes