Hi! Same problem for me! Runs perfectly in my IDE (Eclipse, configured to use the version of Python that come with ArccGIS); Works the first time the geoprocessing is invoked; Crash the second (and next) times it is invoked Here is a minimal code snippet that allow to reproduce the problem:
import arcpy
import pyodbc
inputString = arcpy.GetParameterAsText(0)
arcpy.SetParameterAsText(1, 'echo:'+inputString)
try:
arcpy.AddMessage("START")
conn=pyodbc.connect('DRIVER={SQL Server};SERVER=DGENV-LPD.aris-lux.lan\LPD;DATABASE=lpd_proto;UID=lpd_proto;PWD=lpd_proto')
cursor = conn.cursor()
cursor.execute("INSERT INTO IMPORT_BATCH (batchDate,lifeProjectNumber,archiveName,stage) VALUES ('2012-03-26 17:16:37.4900000','Minimal test','Grrrrr...','TEMP')")
r=cursor.execute("SELECT @@IDENTITY")
f=cursor.fetchone()
cursor.close()
conn.commit()
arcpy.AddMessage("DONE")
except Exception,e:
arcpy.AddMessage("e="+str(e))
finally:
conn.close()
It is wrapped in a toolbox which has one input/output String parameter. Here are the output of the script (when invoked from Firefox, as REST geoprocessing service) First execution :
Results:
out: echo:test
Messages:
esriJobMessageTypeInformative: Executing (InputScriptLabel): InputScript test
esriJobMessageTypeInformative: Start Time: Tue Mar 27 11:27:04 2012
esriJobMessageTypeInformative: Running script InputScript...
esriJobMessageTypeInformative: START
esriJobMessageTypeInformative: DONE
esriJobMessageTypeInformative: Completed script InputScript...
esriJobMessageTypeInformative: Succeeded at Tue Mar 27 11:27:04 2012 (Elapsed Time: 0.00 seconds)
Next executions :
Results:
out: echo:test
Messages:
esriJobMessageTypeInformative: Executing (InputScriptLabel): InputScript test
esriJobMessageTypeInformative: Start Time: Tue Mar 27 11:23:31 2012
esriJobMessageTypeInformative: Running script InputScript...
esriJobMessageTypeInformative: START
esriJobMessageTypeInformative: e='NoneType' object is not callable
esriJobMessageTypeInformative: Completed script InputScript...
esriJobMessageTypeInformative: Succeeded at Tue Mar 27 11:23:31 2012 (Elapsed Time: 0.00 seconds)
Using the old school debbuging technique, using log (arcpy.AddMessage actually), I found out the the exception is thrown by "f=cursor.fetchone()". Removing this instruction prevents the service to crash ... but does not longer do the work ... 😞 My configuration is as follow: Windows Server 2008 R2 Standart (64bit) ArcGIS Server 10 Python 2.6 (bundled version) pyodbc-3.0.2 32b (pyodbc-3.0.2.win32-py2.6.exe, because 64bit does not work because of a "Not a valid Win32 application" error). Microsoft SQL Server 2008 R2 (64b) Help would be very appreciated! Thanks a lot, Octave
... View more