I have a python script that creates a temporary feature class, creates a feature layer from the temporary feature class, uses the feature layer, then deletes the feature layer and the feature class. When I try to publish the python script as a Geoprocessing service I get an ERROR saying that my project contains a broken project data source on my temporary feature layer. So far my work around is to leave the temporary feature class in my workspace. Is there a way to delete it before the process completes? Here is the code snippet that generates the error:
acadian_holder_fpath = "\\\\my_server\\GIS\Geodatabases\\Acadian_Holder.gdb\\Acadian_Holder_Dataset\\Acadian_Holder" xxcrown_fpath = "\\\\my_server\\GIS\\Geodatabases\\Temp_WorkSpace.gdb\\xxholder_src" arcpy.analysis.Select(acadian_holder_fpath,xxcrown_fpath,"LOC in ('BB','BC','BM','IQ','JC','JN','JS','JW','PH','QB','RB','RG','RS','SQ','SV','UG')") dnr_regions_fpath = "\\\\my_server\\GIS\\Geodatabases\\Acadian.gdb\\dnr_regions" xxregions_fpath = "\\\\my_server\\GIS\\Geodatabases\\Temp_Workspace.gdb\\xxregions_src" arcpy.analysis.Intersect([xxcrown_fpath,dnr_regions_fpath],xxregions_fpath) arcpy.management.Delete(xxcrown_fpath) at_road_network_fpath = "\\\\my_server\\GIS\\Geodatabases\\connection_to_my_sde.SDE\\AT_Road_Network" # Use select by location instead of intersect so we get the entire road if it exits crown land. at_road_network_flayer = arcpy.management.MakeFeatureLayer(at_road_network_fpath,"at_road_network_flayer") xxregions_flayer = arcpy.management.MakeFeatureLayer(xxregions_fpath,"xxregions_flayer") # Select YTD roads where_clause = "Region = 1 or Region = 3 or Region = 4" arcpy.management.SelectLayerByAttribute(xxregions_flayer, "NEW_SELECTION", where_clause) arcpy.management.SelectLayerByLocation(at_road_network_flayer, "INTERSECT", xxregions_flayer) # Do stuff with at_road_network_flayer # Delete the temporary feature class arcpy.management.Delete(xxregions_flayer) del xxregions_flayer arcpy.management.Delete(xxregions_fpath)