I am attempting to create a Layer in and MXD from a Mosaic Dataset utilizing:
Which is correctly creating the layer object, and storing it in the MXD, however when I attempt to delete the MXD (after copying to a new location) I get the following error:
WindowsError: [Error 32] The process cannot access the file because it is being used by another process:
I can isolate the error to the MakeMosaicLayer and have attempted to call SaveToLayerFile on the created "temporary" Layer file but the error persists. I can also confirm that the file is being help by an instance of python.exe, which indicates to me that the MakeMosaicLayer call internally spins up another python instance holding the reference.
Are there any work around for this issue someone can recommend short of "Don't attempt to delete the file"