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

Jump to solution
04-18-2017 07:32 AM
by Anonymous User
Not applicable

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'
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)
print "Editor Commands."

#create curser on fc
#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        
print "Updated Rows."
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.



0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

It was an SDE locking issue, just in case anyone in the future is looking this up.

View solution in original post

4 Replies
by Anonymous User
Not applicable

It was an SDE locking issue, just in case anyone in the future is looking this up.

MVP Esteemed Contributor

Just in case it is a locking issue causes by a step in your script, you can use  time.sleep()  to pause what a lock is released.  I have to do this with some of my scripts which seem to run faster than the system is responding.  for example

import time
def mySleep(secs):
     print("     zzz...sleeping {0} seconds to allow network file status to catch up....".format(secs))
MVP Honored Contributor

I had this same error but it came up in ModelBuilder in ArcGIS Pro 2.0. It was a file geodatabase and I just closed my project and opened it again, and it ran just fine. Is there a way to put in a sleep timer thing in #ModelBuilder‌?

0 Kudos
New Contributor

After reading all sorts of fixes for this issue online, neither worked for my situation and ended up finding out that table that I was trying to insert need to have edit rights under "Privileges"!  haha

0 Kudos