Background runs
A table of 100,000 rows takes about an hour. Instead of waiting on the CALL, run it in the background: the
app queues the run, returns at once, and does the work in its own serverless task.
Start a background run
run_tool_async takes the same arguments as run_tool:
Code
It returns {run_id, status: 'QUEUED', output_table}. Company searches have the same form:
search_companies_async(filters, output_table, max_results).
In the Streamlit app, Run in the background on the Enrich a table page (and on Find companies) does the same, and takes you to History.
Follow progress
Code
progress_pct is the share of rows done. The History page shows the same as progress bars.
Cancel
Code
A running run stops after the rows it is working on (up to 1,000); a queued run never starts. Rows already done are kept, and you can resume the run later.
Good to know
- Background runs need the app's
EXECUTE TASKandEXECUTE MANAGED TASKprivileges (see Installation). Without them, the call explains what to approve; regular runs still work. - The serverless task uses Snowflake compute, billed to your account like any serverless task. Lookups wait on the network, so it stays small.
- Runs are processed one at a time, oldest first.