Arcp randomly crashes when runing iterated cost distance tool (spatial analyst)

Discussion created by sebastian_4m on Sep 24, 2012
Latest reply on Oct 3, 2012 by csny490
Hi all,
I'm experiencing this random error when I run a record-iterated cost distance script in arcpy. The code I have used to work well in arcgis 10.0, but now in 10.1 is giving me only headaches. I want to outline that the code fails randomly at different stages of the iteration, however it has never gone past the 200th record.

Traceback (most recent call last):
File "C:\Users\urban4m_02\Documents\MSAu4m\py_codes\", line 67, in <module>
outCostDist = CostDistance(row[2], cost, maxDist*factor)
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\sa\", line 640, in CostDistance
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\sa\", line 47, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\sa\", line 634, in wrapper
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\", line 484, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 999999: Error executing function.
Workspace or data source is read only.
Workspace or data source is read only.
ERROR 010029: Unable to create the raster C:\Users\urban4m_02\Documents\MSAu4m\scratch.gdb\CostDis_f0F01. Cost Distance mapping Failed
ERROR 010067: Error in executing grid expression.
Failed to execute (CostDistance).

I'm running the iteration using
with arcpy.da.SearchCursor(inputFC,["OID@","SHAPE@XY","SHAPE@","ICOUNT"]) as cursor:
    for row in cursor:
        outCost = CostDistance(row[2], costSurface, maxDist)

and I have tried fixing it by adding
but no luck so far.

Has anybody else experienced similar issues when running an iterated spatial analyst tool in arcpy?