Thanks Chris. The script with the subprocess did exactly what you said it would and flooded the processor with parallel processes.Here is my code with just one python script where the memory usage keeps increasing until the python scripts freezes up. The script is meant to loop through a selected directory, get the mxds and resource the SDE layers from the original SDE connection to a different SDE connection. You can open up Task Manager while running this script and see how memory usage for the pythonw.exe process keeps increasing. Please note that you will need to run this script on a directory with a good number of mxd files that have many SDE layers in order to see the performance hit.
import os, sys, string, arcpy
mxd_match = ".mxd"
Directory_Search = r"\\server00\e$\restore5\Experiment\Test_10"
new_connPrefix = r"C:\Documents and Settings\Application Data\ESRI\Desktop10.0\ArcCatalog"
def Conn_Info(usr):
if usr == "user01":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
return new_connection
elif usr == "user02":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@development.sde"
return new_connection
elif usr == "user03":
new_connection = new_connPrefix + "\\" + usr + "_dir_conn@production.sde"
return new_connection
del new_connection
for root, dirs, files in os.walk(Directory_Search):
# for root, dirs, files in os.walk(arcpy.GetParameterAsText(0)):
fListLength = len(files)
if (fListLength != 0):
n = 0
for f in files:
full_path = root + "\\" + str(f)
if f.endswith(mxd_match):
mxd = arcpy.mapping.MapDocument(full_path)
for lyr in arcpy.mapping.ListLayers(mxd):
try:
if lyr.supports("DATASOURCE"):
if lyr.supports("SERVICEPROPERTIES"):
servProp = lyr.serviceProperties
user = str(servProp.get('UserName', 'N/A'))
new_conn = Conn_Info(user)
lyr.replaceDataSource(new_conn, "SDE_WORKSPACE", lyr.datasetName)
except:
print arcpy.GetMessages(2)
del lyr
try:
# mxd.saveACopy(root + "\\" + f[:-4] + "_New.mxd", "9.3")
mxd.save()
except:
print arcpy.GetMessages(2)
del mxd
del full_path
Thanks for all your help!!