> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Job Management

> Manage and track async jobs using the Python SDK

The SDK provides methods to retrieve job status, cancel jobs, and list jobs for async operations.

***

## Retrieve Job Status

Get the status and results of an async job:

```python theme={null}
from pathlib import Path
from reducto import Reducto

client = Reducto()

# Start an async job using run_job()
upload = client.upload(file=Path("document.pdf"))
async_result = client.parse.run_job(input=upload.file_id)
job_id = async_result.job_id

# Retrieve job status
job = client.job.get(job_id)

# Check status
if job.status == "Completed":
    print("Job completed!")
    print(job.result)
elif job.status == "Pending" or job.status == "Idle":
    print("Job still processing...")
elif job.status == "Failed":
    print(f"Job failed: {job.reason}")
```

***

## Cancel Job

Cancel a running job:

```python theme={null}
from reducto import Reducto

client = Reducto()

# Start async job
async_result = client.parse.run_job(input=upload.file_id)

# Cancel it
client.job.cancel(async_result.job_id)
```

***

## List Jobs

Get a list of your jobs with pagination:

```python theme={null}
from reducto import Reducto

client = Reducto()

# List recent jobs (default: 100 per page, max: 500)
jobs = client.job.get_all()

for job in jobs.jobs:
    print(f"Job {job.job_id}: {job.status}")

# With pagination parameters
jobs = client.job.get_all(
    limit=50,              # Max jobs per page (default: 100, max: 500)
    cursor=None,           # Use next_cursor from previous response
    exclude_configs=True   # Exclude raw_config to reduce response size
)

# Paginate through all jobs
cursor = None
while True:
    jobs = client.job.get_all(cursor=cursor, limit=100)
    for job in jobs.jobs:
        print(f"Job {job.job_id}: {job.status}")
    
    if not jobs.next_cursor:
        break
    cursor = jobs.next_cursor
```

### Parameters

| Parameter         | Type          | Default | Description                                 |
| ----------------- | ------------- | ------- | ------------------------------------------- |
| `limit`           | `int`         | 100     | Maximum jobs per page (max: 500)            |
| `cursor`          | `str \| None` | None    | Pagination cursor from previous response    |
| `exclude_configs` | `bool`        | False   | Exclude raw\_config to reduce response size |

***

## Polling for Completion

Poll for job completion:

```python theme={null}
import time
from pathlib import Path
from reducto import Reducto
import reducto

client = Reducto()

# Start async job
upload = client.upload(file=Path("document.pdf"))
async_result = client.parse.run_job(input=upload.file_id)
job_id = async_result.job_id

# Poll until complete
while True:
    job = client.job.get(job_id)
    
    if job.status == "Completed":
        print("Job completed!")
        print(job.result)
        break
    elif job.status == "Failed":
        print(f"Job failed: {job.reason}")
        break
    
    print(f"Status: {job.status}, waiting...")
    time.sleep(2)  # Wait 2 seconds before checking again
```

***

## Job Status Values

| Status      | Description                                        |
| ----------- | -------------------------------------------------- |
| `Pending`   | Job is queued, waiting for a worker                |
| `Idle`      | Job is idle, waiting to be picked up               |
| `Completed` | Results are ready                                  |
| `Failed`    | Processing failed (check `job.reason` for details) |

***

## Error Handling

```python theme={null}
from reducto import Reducto
import reducto

try:
    job = client.job.get(job_id)
except reducto.NotFoundError:
    print("Job not found")
except reducto.APIConnectionError as e:
    print(f"Connection failed: {e}")
except reducto.APIStatusError as e:
    print(f"Error: {e.status_code} - {e.response}")
```

***

## Next Steps

* Learn about the [async client](/sdk/python/async) for concurrent processing
* Explore [error handling](/sdk/python/error-handling) for robust applications
