Skip to content

Commit 328a672

Browse files
authored
Document jobs.wait_for_job (tableau#909)
This commit adds the corresponding documentation for PR tableau#903
1 parent 7892b42 commit 328a672

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/api-ref.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,6 @@ Source files: server/endpoint/jobs_endpoint.py
13541354

13551355
```py
13561356
jobs.get_by_id(job_id)
1357-
13581357
```
13591358

13601359
Gets information about the specified job.
@@ -1412,6 +1411,40 @@ Returns the `JobItem` requested.
14121411
```
14131412

14141413

1414+
<br>
1415+
<br>
1416+
1417+
#### jobs.wait_for_job
1418+
1419+
1420+
```py
1421+
jobs.wait_for_job(job_id, *, timeout=None)
1422+
```
1423+
1424+
Waits until a given job succesfully finishes.
1425+
Repeatedly polls the server using `jobs.get_by_id` until the job completed.
1426+
It uses an exponentially increasing sleep time between polls to guarantee a snappy response time for fast-running jobs while not putting overly large load on the server for long-running jobs.
1427+
1428+
In case the job fails or is cancelled, `wait_for_job` will raise an exception.
1429+
1430+
**Parameters**
1431+
1432+
Name | Description
1433+
:--- | :---
1434+
`job_id` | The `job_id` specifies the id of the job that we want to wait for
1435+
`timeout` | Optional timeout interval in seconds. `wait_for_job` will raise a `TimeoutError` if the job is not finished after waiting for `timeout` seconds.
1436+
1437+
1438+
**Returns**
1439+
1440+
Returns the final `JobItem`.
1441+
1442+
Usually, you can just discard the return value without checking the job status. In case the job wasn't succesful, `wait_for_job` would have already raised an exception. For advanced scenarios, he returned `JobItem` might still be interesting to access e.g. start and end time or `notes`.
1443+
1444+
**Example**
1445+
1446+
See the `update_datasource_data.py` or `refresh.py` sample in the Samples directory.
1447+
14151448
<br>
14161449
<br>
14171450

0 commit comments

Comments
 (0)