I have a Geoprocessing Service that is complicated, but the issue I'm having revolves around a few very simple steps. I'm trying to take in a path to a feature class that sits within SDE, create a temporary feature layer out of it (arcpy.MakeFeatureLayer_management), and then use a search cursor (arcpy.da.SearchCursor) to count the records in the feature class. I am not using ArcMap or anything outside of arcpy for this, the layer is stored in-memory and dumped after being used. The script itself works fine up until the point that new data is added and then the results become inconsistent with the actual data.
Here is an example of the issue:
- Feature Class has 0 records.
- The Model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and returns a count of "0 records found." (OK)
- The Geoprocessing Service itself also returns "0 records found." (OK)
- 1 record is added to the Feature Class through some means in an edit session (programatically, through ArcMap, etc.)
- The model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and still returns a count of "0 records found." (INCORRECT)
- The Geoprocessing Service itself also returns "0 records found." (INCORRECT)
The only way I've discovered that the model will display the correct record count when run from Desktop is to close/open all ArcGIS Desktop applications and re-run it. Likewise, for the Geoprocessing Service to display the correct record count, I must restart or republish the Geoprocessing Service.
I'm hoping this issue has a simple resolution, but I'm scratching my head over it as of right now. If someone needs sample code, I can provide it, but the first paragraph is the script in a nutshell.