I have a python script that runs every hour or so as a windows scheduled task and does some updates to an ArcGIS Online hosted feature layer using the layer.calculate function. Every so often (once every couple of days) it hangs. The layer it hangs on only has 1600 records and the query reduces that to 26 records so it isn't a problem of the server being overwhelmed. I could live with it throwing an error, but the hang stops all of the subsequent automation processes which is a big problem. Any ideas on how to make this more reliable, or at least get an error back?
Here is the python code
def __do_calculate (org_id, lyr, query, expression):
logger.debug(f"{org_id}: Submitting calculate '{query}' '{expression}'")
future_job = lyr.calculate(where=query, calc_expression=expression, future=True)
logger.debug(f"{org_id}: Checking calculate result")
result = future_job.result()
logger.debug(f"{org_id}: Calculate complete. {result}")
return
Here is the log file from when it works
2026-09-29 23:02:14,916 - INFO - sync_org_users - DEVOrgA: BeeOccurrenceAreas_Data Member List: [DMorrison_01_ROW],[ROW_Admin],[chernandez_ERC],[don.morrison],[don.morrison.2000@gmail.com],[dsalas4_ERC],[iriscald]
2026-09-29 23:02:14,916 - DEBUG - sync_org_users - DEVOrgA: Submitting calculate 'Org_ID='DEVOrgA'' '[{'field': 'Org_Users', 'value': '[DMorrison_01_ROW],[ROW_Admin],[chernandez_ERC],[don.morrison],[don.morrison.2000@gmail.com],[dsalas4_ERC],[iriscald]'}]'
2026-09-29 23:02:15,133 - DEBUG - sync_org_users - DEVOrgA: Checking calculate result
2026-09-29 23:02:18,614 - DEBUG - sync_org_users - DEVOrgA: Calculate complete. {'layerName': 'BeeOccurrenceAreas_Data', 'submissionTime': 1790740935050, 'lastUpdatedTime': 1790740938567, 'recordCount': 26, 'status': 'Completed'}
Here is the log file when it hangs
2026-09-30 01:11:35,798 - INFO - sync_org_users - DEVOrgA: BeeOccurrenceAreas_Data Member List: [DMorrison_01_ROW],[ROW_Admin],[chernandez_ERC],[don.morrison],[don.morrison.2000@gmail.com],[dsalas4_ERC],[iriscald]
2026-09-30 01:11:35,799 - DEBUG - sync_org_users - DEVOrgA: Submitting calculate 'Org_ID='DEVOrgA'' '[{'field': 'Org_Users', 'value': '[DMorrison_01_ROW],[ROW_Admin],[chernandez_ERC],[don.morrison],[don.morrison.2000@gmail.com],[dsalas4_ERC],[iriscald]'}]'
2026-09-30 01:11:36,005 - DEBUG - sync_org_users - DEVOrgA: Checking calculate result