arcpy.da.Editor Hanging up Script Tool

179
6
Jump to solution
2 weeks ago
EvanMyers1
Occasional Contributor

Has anyone run into the issue where 'with arcpy.da.Editor(workspace, multiuser_mode=True):'  doesn't do anything?  In my case, my script works up until this point, and just endlessly runs.  It doesn't reach the 'arcpy.AddMessage('starting edit')' part or anything within the with statement.  I end up having to ctrl+alt+del Pro just to get out.  

import arcpy
import os
import sys
import geopandas

userInput = arcpy.GetParameterAsText(0)

inputDesc = arcpy.Describe(userInput)
workspace = os.path.dirname(inputDesc.catalogPath)
wsDesc = arcpy.Describe(workspace)
versioned = inputDesc.isVersioned
if hasattr(wsDesc, "datasetType") and wsDesc.datasetType == 'FeatureDataset':
    workspace = os.path.dirname(workspace)
with arcpy.da.Editor(workspace, multiuser_mode=False):
    arcpy.AddMessage('starting edit')
    calcCoords(userInput)

 

0 Kudos
1 Solution

Accepted Solutions
EvanMyers1
Occasional Contributor

I am not sure what was preventing edits to the workspace but I ended up having to make a new database and test features to solve the issue.  I still really appreciated the help though!

View solution in original post

0 Kudos
6 Replies
BlakeTerhune
MVP Regular Contributor

Maybe something isn't right with your workspace manipulation. Try messaging out the workspace before you open the editor, then see if it works when you hard code that workspace path (or something else you know to work).

0 Kudos
EvanMyers1
Occasional Contributor

When I print out my workspace I get this:

userInput = "TestAssets"

inputDesc = arcpy.Describe(userInput)
workspace = os.path.dirname(inputDesc.catalogPath)
wsDesc = arcpy.Describe(workspace)
versioned = inputDesc.isVersioned
if hasattr(wsDesc, "datasetType") and wsDesc.datasetType == 'FeatureDataset':
workspace = os.path.dirname(workspace)
print(workspace)
'F:\\GIS\\WORKING FILES\\TestProjects\\TestingDB.gdb'
0 Kudos
BlakeTerhune
MVP Regular Contributor

Okay, that looks fine. Now try an isolated test with the arcpy.da.Editor() with that workspace and see what happens.

workspace = 'F:\\GIS\\WORKING FILES\\TestProjects\\TestingDB.gdb'

with arcpy.da.Editor(workspace, multiuser_mode=False):
    arcpy.AddMessage('starting edit')
    # Nothing else, just leave the script.
EvanMyers1
Occasional Contributor

My script ran successfully.  I used the hard coded filepath, but I will not be able to do that for future use, as the other users keep their databases in different places.

If my script is getting stuck on the workspace, could it be a problem with the database itself?

0 Kudos
BlakeTerhune
MVP Regular Contributor

If that hard coded workspace path worked fine, then it's not a problem with the database. I see you are doing some other workspace path manipulation if the input feature class is in a feature dataset. Try some other variations of the path to see if you can get it to fail when hardcoded. My guess is that you're getting something in the workspace that is causing Editor to hang.

0 Kudos
EvanMyers1
Occasional Contributor

I am not sure what was preventing edits to the workspace but I ended up having to make a new database and test features to solve the issue.  I still really appreciated the help though!

0 Kudos