Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
7  
You can also use arcpy.CreateUniqueName function. –  Alex Markov Oct 12 '12 at 15:48
    
Very handy! I didn't know this existed. –  egdetti Oct 12 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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