Select to view content in your preferred language

The network.analysis.generate_origin_destination_cost_matrix reported a 500 error if the origins or destinations is more than 300 points

2049
10
08-01-2023 07:39 PM
JunzheZhang
Emerging Contributor
To repo this case:
1. Build a random feature set with more than 300 points in Pro
2. Publish it into Enterprise
3. Run the following code with the url of the published feature
4. You will see the error message

If the number of points is less than 300, the code should work. 

Here is my code:
from arcgis.gis import GIS
from arcgis.features import FeatureLayer, Feature, FeatureSet, FeatureCollection, use_proximity

username=''
password=''
gis = GIS('', username, password, verify_cert=False, set_active=True)

import arcgis.network as network
origins=FeatureLayer('')
destinations=FeatureLayer('')
result1 = network.analysis.generate_origin_destination_cost_matrix(origins=origins, destinations=destinations, gis=gis)

Here is the error message:
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\geoprocessing\_support.py in _analysis_job_results(gptool, task_url, job_info, job_id)
    304                 try:
--> 305                     param_result = gptool._con.get(
    306                         result_url, params, token=gptool._token

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in get(self, path, params, **kwargs)
    870             return resp
--> 871         return self._handle_response(
    872             resp,

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in _handle_response(self, resp, file_name, out_path, try_json, force_bytes, ignore_error_key)
   1007                 errorcode = data["error"]["code"] if "code" in data["error"] else 0
-> 1008                 self._handle_json_error(data["error"], errorcode)
   1009             return data

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in _handle_json_error(self, error, errorcode)
   1030         errormessage = errormessage + "\n(Error Code: " + str(errorcode) + ")"
-> 1031         raise Exception(errormessage)
   1032 

Exception: Error getting result parameter
(Error Code: 500)

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15924\8243387.py in <cell line: 5>()
      3 origins=FeatureLayer('https://arcgis.reyesholdings.com/server/rest/services/Hosted/test_OD/FeatureServer/0')
      4 destinations=FeatureLayer('https://arcgis.reyesholdings.com/server/rest/services/Hosted/test_OD/FeatureServer/0')
----> 5 result1 = network.analysis.generate_origin_destination_cost_matrix(origins=origins, destinations=destinations, 
      6                                                                        gis=gis)

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\network\_od.py in generate_origin_destination_cost_matrix(origins, destinations, travel_mode, time_units, distance_units, analysis_region, number_of_destinations_to_find, cutoff, time_of_day, time_zone_for_time_of_day, point_barriers, line_barriers, polygon_barriers, uturn_at_junctions, use_hierarchy, restrictions, attribute_parameter_values, impedance, origin_destination_line_shape, save_output_network_analysis_layer, overrides, time_impedance, distance_impedance, output_format, gis, future)
    945     if future:
    946         return job
--> 947     return job.result()
    948 
    949 

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\geoprocessing\_job.py in result(self)
    234         elif self._is_ortho:
    235             return self._process_ortho(self._future.result())
--> 236         return self._future.result()
    237 
    238     def _process_ortho(self, result):

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\concurrent\futures\_base.py in result(self, timeout)
    444                     raise CancelledError()
    445                 elif self._state == FINISHED:
--> 446                     return self.__get_result()
    447                 else:
    448                     raise TimeoutError()

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\concurrent\futures\_base.py in __get_result(self)
    389         if self._exception:
    390             try:
--> 391                 raise self._exception
    392             finally:
    393                 # Break a reference cycle with the exception in self._exception

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\concurrent\futures\thread.py in run(self)
     56 
     57         try:
---> 58             result = self.fn(*self.args, **self.kwargs)
     59         except BaseException as exc:
     60             self.future.set_exception(exc)

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\geoprocessing\_support.py in _future_op(gptool, task_url, job_info, job_id, param_db, return_values, return_messages)
    321 
    322     job_info = _analysis_job_status(gptool, task_url, job_info)
--> 323     resp = _analysis_job_results(gptool, task_url, job_info, job_id)
    324 
    325     # ---------------------async-out---------------------#

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\geoprocessing\_support.py in _analysis_job_results(gptool, task_url, job_info, job_id)
    307                     )
    308                 except:
--> 309                     param_result = gptool._con.get(result_url, params)
    310 
    311                 job_value = param_result.get("value")

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in get(self, path, params, **kwargs)
    869         if return_raw_response:
    870             return resp
--> 871         return self._handle_response(
    872             resp,
    873             file_name,

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in _handle_response(self, resp, file_name, out_path, try_json, force_bytes, ignore_error_key)
   1006                     return data
   1007                 errorcode = data["error"]["code"] if "code" in data["error"] else 0
-> 1008                 self._handle_json_error(data["error"], errorcode)
   1009             return data
   1010         else:

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py in _handle_json_error(self, error, errorcode)
   1029 
   1030         errormessage = errormessage + "\n(Error Code: " + str(errorcode) + ")"
-> 1031         raise Exception(errormessage)
   1032 
   1033     def post_multipart(

Exception: Error getting result parameter
(Error Code: 500)
Tags (2)
0 Kudos
10 Replies
JunzheZhang
Emerging Contributor

Hi,

After several restarts, it works. Thanks. 

0 Kudos