mtaraldsen

Geoprocessing Service Only Runs Once

Discussion created by mtaraldsen on Jun 1, 2014
Latest reply on Jun 2, 2014 by iamurray
Hello,

I am trying to publish an ArcGIS geoprocessing service in 10.2 I have a script setup that will run multiple times through Pycharm, but when I run it in ArcGIS it will run once and return this error:

Traceback (most recent call last):
  File "C:\Users\\Desktop\git\GeoprocessingService.py", line 477, in <module>
    main()
  File "C:\Users\Desktop\git\GeoprocessingService.py", line 372, in main
    cur)
  File "C:\Users\Desktop/git\GeoprocessingService.py", line 136, in value_query
    results = cur.fetchall()
  File "C:\Python27\ArcGIS10.2\lib\site-packages\psycopg2\extras.py", line 81, in fetchall
    res = super(DictCursorBase, self).fetchall()
  File "C:\Python27\ArcGIS10.2\Lib\decimal.py", line 543, in __new__
    m = _parser(value.strip())
TypeError: 'NoneType' object is not callable

Failed to execute (Script).

The script itself is 800 lines, but here is the query I have been running that errors out:
def value_query(id_field, id, value_fields, start_date, end_date, date_field, table, cur):
    query2 = "SELECT "
    for field in value_fields:
        query2 += "NULLIF({0}, '-999')::NUMERIC(6,2),".format(field)
    query2 += "{0} " \
            "FROM {1} " \
            "WHERE {2} = '{3}' AND {0} BETWEEN '{4}' AND '{5}' " \
            "ORDER BY {0} ASC;".format(date_field, table, id_field, id, start_date, end_date)
    #print "This is Query:"
    #print query
    arcpy.AddMessage("{0}".format(query2))
    cur.execute(query2)

    results = cur.fetchall()

    #print "These are value query results:\n\n {0}".format(results)
    return results



Like I said it runs once in ArcGIS then errors out. However, if I close Arc completely and run the exact same script again, it runs once then stops. I feel like there may be some sort of caching or something that Arc does, but am completely stumped.

Outcomes