8

i am using a python script that's eliminating small polygons from a feature class. this script creates temporary feature classes with fixed (hardcoded) names in the "in_memory" workspace. example:

arcpy.CopyFeatures_management("in_fc","in_memory/item_a")

it's a fairly reusable script, so i use it at many points in a geoprocessing chain.

am i in danger, that the same script called twice from different processes (at the same time) will have a conflict at, for example "in_memory/item_a" ? or are the "in_memory" workspaces seperate for each process?

i am using ArcInfo 10.0.

1 Answer 1

8

To test out your question, I wrote up a quick script that I ran two copies of simultaneously- one as a script tool in ArcMap and one in Pythonwin. Somewhat to my surprise, I was unable to run them at the same time because the "in_memory" workspace was shared. There is a way around this, however. You can add in an output check to determine if the file in memory exists, and name it something else if so:

i=0
check = 0
while check == 0:
    memoryFeat = "in_memory" + "\\" + "testMemoryFeature" + str(i)
    if arcpy.Exists(memoryFeat):
        i+=1
    else:
        check = 1

This will attempt to name your in memory feature testMemoryFeature0. If that memory feature already exists, it will attempt to name it testMemoryFeature1, and so on until it finds a name that will suffice.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.