michael_rich

ListWorkspaces returns incorrect results running out-of-process

Discussion created by michael_rich on Nov 2, 2011
Latest reply on Nov 2, 2011 by mzcoyle
I have discovered what appears to be a problem with ListWorkspaces when running a python script in a script tool that is run out-of-process.  When run in-process or running the file from the command prompt yields the correct results.  the reason I am trying to run out-of-process is I am developing a multiprocess script that must be run out-of-process.

Here's the code:
import arcpy, os
from arcpy import env

env.workspace = 'C:/ArcGIS/DeveloperKit10.0/Samples/data'
ws = arcpy.ListWorkspaces()
for w in ws:
    arcpy.AddMessage(w)

arcpy.AddMessage('\n' + str(len(ws)) + ' workspaces' + '\n')

ws = 'C:/ArcGIS/DeveloperKit10.0/Samples/data/SanFrancisco/SanFrancisco.gdb'
env.workspace = ws
ds = arcpy.ListDatasets()
for d in ds:
    arcpy.AddMessage(d)

arcpy.AddMessage('\n' + str(len(ds)) + ' datasets' + '\n')

for d in ds:
    env.workspace = ws + '/' + d
    fc = arcpy.ListFeatureClasses()
    for f in fc:
        arcpy.AddMessage(f)

    arcpy.AddMessage('\n' + str(len(fc)) + ' feature classes' + '\n')
    


The ListDatasets and ListFeatureClasses methods seem to return the correct results either way (out-of-process or in-process).  It's the ListWorkspaces that gives me 7 out-of-process and 28 in-process.

Attached is a toolbox containing the script tool.  Right-click the tool and check/un-check Run in-process to test.  Can anyone else verify this problem?  Don't worry about the performance, yes in-process will run much faster and this is noted in many other forums as a problem/limitation of running out-of-process.

Attachments

Outcomes