I now seem to be getting a sort of intermittent error. Sometimes the dissolve in the code snippet above will work, and sometimes it won't, sometimes it will fail on the 3rd loop. If it does work, the next process, Add Field, will (sometimes) be unable to acquire a schema lock.
Just now, for example, during the first loop, everything worked, during the second loop the dissolve worked, and the add field and calculate field were unable to obtain a schema lock, and during the 3rd loop the dissolve failed (it still got through the if TestSchemaLock: part, but then failed with a schema lock error).
I have tried the following to try and fix the schema locking error, all to no avail:
- Restart computer, clean out temp folder
- Create new folder to store interim files
- Create new folder to set as scratch workspace
- Add del row and del rows line after search cursor
- Run every process as a separate function
- Create short interim file names (a,b,c,d etc...)
- Save all outputs to a location with a short path (F:\Lorna\Temp)
- I am not running ArcCatalog or ArcMap
- Copy the "locked" file using CopyFeatures_management before running dissolve
I have no more ideas to try.