I am having a very strange issue with a geo-processing service published to my 10.41 ArcGIS server instance. I wrote a python script tool (.tbx) that basically takes some input parameters and generates a file GDB wrapped up in a zip archive. Rather than use the scratch workspace, the script simply outputs the resulting zip archive to the output directory on the server machine. Any intermediate files created during script execution are placed in a temp directory on the server machine. If no parameters are fed to the script, the script should literally do nothing. It should just complete execution and the job should finish.
After successfully publishing the script tool as an Asynchronous GP service, if I go to the REST page and submit a job with sample parameters, the code behind the service appears to execute without any issue (i.e. the intermediate files and directories are all created in the proper temp location on the server machine, the final output zip archive is generated and placed in the specified output location on the server machine, and the intermediate files and directories are successfully removed from the server machine). I can look into the output directory for my server machine and see my result zip archive sitting in the directory, so I know the script is generating the output result. The final step of the script is to remove the intermediate files and directories created during execution. This happens in a finally block. The intermediate files and directories are indeed removed, so I'm pretty sure the script is executing to completion. HOWEVER, the status of the geoprocessing job remains 'esriJobExecuting'. The status of the job remains this way until the service reaches the maximum usage time and terminates with a status of 'esriJobFailed'.
What's even stranger is that this same behavior occurs even if no parameters are fed to the service. As I stated, if no parameters are fed to the script, the script doesn't do anything (no processing of any kind), it just completes script execution. But the job status for the job remains 'esriJobExecuting' until reaching max usage time and fails. I'm not quite sure what would be causing the job to still be executing, as there is nothing in the script that would cause a hang-up if there are no parameters fed to it.
To thicken the plot a little bit, the same exact script tool published to my 10.21 ArcGIS server instance as a GP service works without issue. I can call the GP service either from the REST service page or from my web application, using an ArcGIS JS API Geoprocessor instance, and it executes the service job, completely executes the script code behind the service and finishes executing the job with a status of 'esriJobSucceeded'.
Has anyone experienced a GP service that stays in 'esriJobExecuting' status, even though it appears the actual code behind the service has completed execution? There is probably a hacky workaround I can implement to get around this issue in my web application, but I'd like to avoid this is if I can, and just figure out what changes I need to make to either my code or ArcGIS server config to get this to work properly. Any help or insight is greatly appreciated.