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
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.
-
7You can also use arcpy.CreateUniqueName function.Alex Markov– Alex Markov2012年10月12日 15:48:26 +00:00Commented Oct 12, 2012 at 15:48
-
Very handy! I didn't know this existed.bluefoot– bluefoot2012年10月12日 15:50:36 +00:00Commented Oct 12, 2012 at 15:50