I have a geoprocessing task that uses pyodbc to query a database. The tool works fine when run on the local desktop, but when deployed on the server, it fails the second time round i.e. it works the first time, but when it is run again it crashes. Running again then works, but running again crashes etc. The server logs reveal the task �??crashes�??, whilst .dmp files reveal an attempt to read or write to protected memory.
I then included in the code explicit delete for variables and even a gc.collect() call, and the latter seems to have the effect of making the crash occur every 3rd run as opposed to every 2nd.
I have applied SP1 (ArcGIS 10.1), however, this has only had a marginal improvement in that instead of an error being thrown up each 2nd/3rd run, it now just hangs until you cancel it, re-run it and the pattern continues.
Any insights into how to work around this would be great.