Just was trying out multiprocessing for exporting subsets of many featureclasses. Does anyone have experience with this? Something I would like to do is multiprocess a function with multiple variables. multiprocessing.Pool.map does not allow for this. It would be cleaner to have the clipFeature, and output directory as variables for clpFc2Shp. Here is my script example where the Feature dataset has 20 featureclasses for export. Yes I know this will spawn as many processes as there are processors :<|
import arcpy, os, multiprocessing, re
def clpFc2Shp(fc):
#export fc to output directory
print "Clipping: " + fc
print "\tto " + fc + ".shp"
inFD = r"T:\Base_Data.gdb\Base_Map_20K"
arcpy.env.workspace = inFD
clpFeature = r"T:\KB_REGION.shp"
outFolder = r"T:\shpOut"
outShp = os.path.join(outFolder,fc + ".shp")
try:
if not arcpy.Exists(outShp):
arcpy.Clip_analysis(fc,clpFeature,outShp)
print "\t...done"
except:
print "\t...failed clp"
def main():
#Creates a pool class and runs the # of clips equal to the # of featureclasses.
inFD = r"T:\Base_Data.gdb\Base_Map_20K"
arcpy.env.workspace = inFD
fcList = arcpy.ListFeatureClasses()
pool = multiprocessing.Pool()
pool.map(clpFc2Shp,fcList)
pool.close()
pool.join()
if __name__ =='__main__':
main()