I ran into the exact same problem. My Python script fails with "Fatal ERROR (INFDEF)" because the number of temporary files is apparently too high for the info grid format.
Is there any workaround? Can I control the format of these temporary files so they can be stored as IMG instead? Is there a way to cleanup the temporary files during the script run? These are not "intermediate" files, ArcGIS seems to create them behind the scenes. My workspace and scratch workspace are set to two different file geodatabases but these temporary files seems to be created in C:\Users\<username>\AppData\Local\Temp regardless. Can I control where these files get created?
In case of the TabulateArea tool, the temporary rasters get created when input zones are features and not a raster. The only way I found around this issue was to convert my zones from polygons to raster before the tabulate area is called. That way, it is possible to control where the raster is created and so it can be deleted afterwards.
Other tools in the Zonal Statistics toolset may require similar approach to avoid the Fatal ERROR (INFDEF).
I also found that this error may occur with other SpatialAnalyst tools in Python when you do not explicitly save them to hard drive - ArcGIS saves temporary rasters to temporary directory and doesn't clean up. Here is how to avoid it:
# when a and b are rasters: c = arcpy.sa.Add(a, b) # c is is "temporary" and resides in temporary folder c.save("c:\sws.gdb\temp") # c is "permanently" saved in specified path and removed from the temporary folder arcpy.management.Delete(c) # c is removed from where it was "permanently" stored
There are rules about how ArcGIS determines the scratch folder but unless you can direct the temporary rasters to a geodatabase or save them as something else than ArcINFO Grids, you are going to run into the same issue.
If you know a more elegant solution, I am eager to hear about it.