ArcGIS python api 1.8.3 for new workforce random network errors

230
2
Jump to solution
12-16-2020 05:04 PM
VictorTey
Esri Contributor

Hi, I am using the pre release 1.8.3 python api for the new workforce. I have code that were working and starting from yesterday, it keep failing randomly in different part of the code with error either 502 or 499 (token required) while trying to automate some work flow on agol (workforce)

I have checked agol status and it is green light all the way. Is there anyone else experiencing the same issue?

agol = GIS(config.agol_credential['url'],
username=config.agol_credential['username'],
password=config.agol_credential['password'])

wf_project_item = agol.content.get(config.wf_project_itemId)
wf_project = workforce.Project(wf_project_item) my code

stack trace:

wf_project = workforce.Project(wf_project_item)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 71, in __init__
self._update_cached_objects()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 85, in _update_cached_objects
self._cached_workers = {w.id: w for w in self.workers.search()}
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\managers.py", line 734, in search
return query_workers(self.project, where)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\_store\workers.py", line 43, in query_workers
worker_features = project.workers_layer.query(where, return_all_records=True).features
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 1540, in query
record_count = self._query(url, params, raw=as_raw)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2556, in _query
raise queryException
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2526, in _query
postdata=params, token=self._token)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 720, in post
force_bytes=kwargs.pop('force_bytes', False))
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 514, in _handle_response
self._handle_json_error(data['error'], errorcode)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 536, in _handle_json_error
raise Exception(errormessage)
Exception: Token Required
Token Required
(Error Code: 499)

 

Re-Running code again worked and re-running the 3rd time without any code change, it error out again.

wf_project = workforce.Project(wf_project_item)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 71, in __init__
self._update_cached_objects()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 84, in _update_cached_objects
self._update_cached_assignment_types()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 77, in _update_cached_assignment_types
self._cached_assignment_types = {a.code: a for a in self.assignment_types.search()}
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\managers.py", line 252, in search
return get_assignment_types_v2(self.project)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\_store\assignment_types_v2.py", line 27, in get_assignment_types_v2
return query_assignment_types(project, '1=1')
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\_store\assignment_types_v2.py", line 36, in query_assignment_types
assignment_type_features = project.assignment_types_table.query(where, return_all_records=True).features
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2966, in query
record_count = self._query(url, params, raw=as_raw)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2556, in _query
raise queryException
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2526, in _query
postdata=params, token=self._token)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 11530, in _token
self._hydrate()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 11509, in _hydrate
self._refresh()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 11452, in _refresh
raise e
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 11445, in _refresh
dictdata = self._con.post(self.url, params, token=self._lazy_token)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 720, in post
force_bytes=kwargs.pop('force_bytes', False))
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 514, in _handle_response
self._handle_json_error(data['error'], errorcode)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 536, in _handle_json_error
raise Exception(errormessage)
Exception: An error occurred.
(Error Code: 503)

 

Last try again:

wf_project = workforce.Project(wf_project_item)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 71, in __init__
self._update_cached_objects()
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\project.py", line 85, in _update_cached_objects
self._cached_workers = {w.id: w for w in self.workers.search()}
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\managers.py", line 734, in search
return query_workers(self.project, where)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\workforce\_store\workers.py", line 43, in query_workers
worker_features = project.workers_layer.query(where, return_all_records=True).features
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 1540, in query
record_count = self._query(url, params, raw=as_raw)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2556, in _query
raise queryException
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\features\layer.py", line 2526, in _query
postdata=params, token=self._token)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 720, in post
force_bytes=kwargs.pop('force_bytes', False))
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 514, in _handle_response
self._handle_json_error(data['error'], errorcode)
File "C:\Users\vtay\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 536, in _handle_json_error
raise Exception(errormessage)
Exception: An error occurred.
(Error Code: 503)

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

have you updated from pre-release?


... sort of retired...

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

have you updated from pre-release?


... sort of retired...
0 Kudos
VictorTey
Esri Contributor

Hi @DanPatterson , I did however I am happy to report today was alot more stable and the script is running fine now.

0 Kudos