Survey.generate_report() — add job timeout and cancel support
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 56/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- api, backend-api-design
Research direction
Start in _survey.py at Survey.generate_report(), then trace the submit, status-polling, and cancel endpoints named in the issue. Verify finite job_timeout handling, TimeoutError, optional cancellation, and jobId or handle exposure; done means a stuck job stops polling and the remote job is cancelled when requested.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
In the example above I Had to cancel it manually, after 2h.
Survey.generate_report() submits a Feature Report job and polls forever with no timeout (internal loop sleeps while esriJobExecuting with no deadline). In batch/ETL PDF generation, a stuck job hangs the process indefinitely. The method also does not return jobId, so callers cannot cancel a hung job via the Survey123 cancel endpoint.
We had to bypass generate_report() and reimplement submit + poll against the same REST API just to add a timeout and a real cancel.
from arcgis.gis import GIS
from arcgis.apps.survey123 import SurveyManager
gis = GIS(url, username, password)
survey = SurveyManager(gis).get("<survey_item_id>")
template = gis.content.get("<report_template_item_id>")
# Can hang forever if the job never leaves esriJobExecuting
# (no timeout kwarg; no jobId returned to cancel)
result = survey.generate_report(
report_template=template,
where="OBJECTID=1",
utc_offset="+00:00",
output_format="pdf",
)
Describe the solution you'd like
Add optional timeout / cancel controls on Survey.generate_report() (or SurveyManager):
job_timeout(seconds) — stop polling after N seconds and raise a clear error (e.g.TimeoutError).cancel_on_timeout— callPOST .../api/featureReport/jobs/{jobId}/cancelso the remote job does not keep running after the client gives up.- Optionally expose
jobId(or a job handle) so callers can cancel/track jobs themselves.
Example:
result = survey.generate_report(
report_template=template,
where="OBJECTID=1",
output_format="pdf",
job_timeout=90, # NEW
cancel_on_timeout=True, # NEW
)
The cancel endpoint already works in practice (POST .../api/featureReport/jobs/{jobId}/cancel → esriJobStatusCancelled).
Describe alternatives you've considered
- Reimplement submit + poll ourselves (current workaround) — duplicate
_survey.pylogic against/createReport/submitJob,/jobs/{id}/status, and/cancel. Works, but fragile if the private API changes. - External process/watchdog timeout — kills the Python process but does not cancel the remote job; wastes credits and leaves orphan jobs.
- Thread + interrupt — still no access to
jobId, so cancel is impossible.
Additional context
- Affected API:
arcgis.apps.survey123.Survey.generate_report - Use case: automated batch PDF Feature Reports in an ETL pipeline (ArcGIS Enterprise / AGOL)
- Related endpoints already used successfully outside the Python API:
POST /api/featureReport/createReport/submitJobGET /api/featureReport/jobs/{jobId}/statusPOST /api/featureReport/jobs/{jobId}/cancel
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 1.1k
- Avg merge
- 2h 40m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Esri/arcgis-python-api
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Esri/arcgis-python-api#2513 · 1 comment ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Esri/arcgis-python-api#2453 · 3 comments ·
-
documentation enhancement
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Esri/arcgis-python-api#2097 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Esri/arcgis-python-api#2537 · 3 comments ·
-
bug
Esri/arcgis-python-api#2527 · 4 comments · 1 assignee ·
All issues in Esri/arcgis-python-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100