forked from kenzuya/unshackle
refactor(api): put the job and worker process channels in job_channel
This commit is contained in:
@@ -160,7 +160,7 @@ full detail:
|
||||
| `track_progress` | list | Per-active-track `{label, progress, speed}` entries. |
|
||||
| `segments_done` | number | Segments downloaded for the track in progress. |
|
||||
| `segments_total` | number | Total segments for the track in progress. |
|
||||
| `speed` | string | Transfer speed of the track in progress, e.g. `4.20 MB/s`. |
|
||||
| `speed` | string or `null` | Transfer speed of the track in progress, e.g. `4.20 MB/s`. `null` when no track downloads. |
|
||||
| `skipped_subtitles` | list | Subtitles that were skipped as non-fatal failures (when `skip_subtitle_errors` is set). |
|
||||
| `skipped_titles` | list | Titles that the run skipped because a requested track or language is missing, each `{title, reason}`. |
|
||||
| `input_prompt` | string or `null` | The prompt the service waits on. Answer it with `POST /api/download/jobs/{job_id}/input`. |
|
||||
@@ -365,7 +365,8 @@ server process. For each job it spawns a separate Python subprocess:
|
||||
python -m unshackle.core.api.download_worker <payload.json> <result.json> <progress.json>
|
||||
```
|
||||
|
||||
Three temporary files bridge the parent and the job worker:
|
||||
Three temporary files bridge the parent and the job worker. `unshackle/core/api/job_channel.py` defines each file
|
||||
and the stdin answer line:
|
||||
|
||||
- **`payload.json`**: the manager writes it before launch. It contains the job ID,
|
||||
service, title ID, and merged parameters.
|
||||
@@ -384,8 +385,8 @@ and blocking work inside the download engine, and makes hard cancellation (killi
|
||||
process) reliable.
|
||||
|
||||
The job worker's exit codes are `0` for success, `1` for a download error, and `2` for bad
|
||||
arguments. Its `result.json` is either `{"status": "success", "output_files": [...]}`
|
||||
or `{"status": "error", "message", "error_details", "error_code", "traceback"}`. If the
|
||||
arguments. Its `result.json` holds `status`, `output_files`, `message`, `error_details`, `error_code` and
|
||||
`traceback`. The `status` is `success` or `error`, and a success leaves the error fields `null`. If the
|
||||
process exits non-zero, or the result is missing or not a success, the parent marks the
|
||||
job `failed` and adopts the job worker's `error_code` (or derives one by categorising the
|
||||
exception).
|
||||
@@ -393,7 +394,9 @@ exception).
|
||||
### How progress reaches the API
|
||||
|
||||
While the job worker operates, the manager polls `progress.json` every **0.5 s** and copies the
|
||||
fields it finds onto the live `DownloadJob`. That is what the `GET` endpoints return.
|
||||
fields it finds onto the live `DownloadJob`. That is what the `GET` endpoints return. The file
|
||||
holds the whole progress record each time, so each field in it replaces the job's value, `0` and
|
||||
`null` too.
|
||||
|
||||
The job worker aggregates progress across all selected tracks. It weights each track's
|
||||
completion fraction by its bitrate, so video and audio dominate the bar and subtitles
|
||||
|
||||
Reference in New Issue
Block a user