stratified_packager.processing.workers
Background zip publishing: the only work that leaves the algorithm thread (SPEC §8.4/§10).
This module MUST NOT import ``qgis`` — zip jobs run on plain
ThreadPoolExecutor threads and touch only zipfile
and the standard library. An AST test enforces this. GeoPackage writing now happens on the
algorithm thread (see building); the algorithm hands each finished bundle here so
the next bundle’s GeoPackages can be built while this one is compressed and published.
A job returns its outcome (the algorithm collects it from the future); cancellation
propagates via a threading.Event the algorithm sets when the feedback is
canceled. Jobs never raise — failures and cancellations are returned as outcomes and the
partial archive is removed (best-effort policy, SPEC §17).
Functions
|
Copy one §11 warm-cache file to its build location on a background thread; never raises. |
|
Assemble and publish one zip on a background thread (SPEC §10); never raises. |
Classes
|
One zip assembly + publish task (SPEC §10); plain data built on the algorithm thread. |
|
The result of one |
- class stratified_packager.processing.workers.ZipJob(zip_rel, members, build_path, final_path, compression_level=6, write_checksum=False)[source]
One zip assembly + publish task (SPEC §10); plain data built on the algorithm thread.
- Parameters:
- __init__(zip_rel, members, build_path, final_path, compression_level=6, write_checksum=False)
- class stratified_packager.processing.workers.ZipOutcome(zip_rel, ok, final_path='', error='')[source]
The result of one
run_zip()call.- __init__(zip_rel, ok, final_path='', error='')
- zip_rel: str
The zip’s output-relative path (matches
ZipJob.zip_rel).
- stratified_packager.processing.workers._check_cancel(cancel, token)[source]
Raise when the run was canceled.
- Parameters:
- Raises:
OperationAbortedError – If cancellation was requested.
- Return type:
- stratified_packager.processing.workers.run_prefetch(source, destination, cancel)[source]
Copy one §11 warm-cache file to its build location on a background thread; never raises.
Submitted before Phase A on
WARM_START_MODE=useruns, so a (possibly remote) cache file is already sitting at the stratum’s build path when its seeded build starts — the build then seeds in place instead of copying on the critical path. Copied chunked viapublish_atomic()(.part+ rename, cancel polled between chunks), so a half-copied file is never mistaken for a seed and a canceled run does not wait out a large remote copy. Best-effort:Falsesends the caller back to the seed-time copy from the original cache file.
- stratified_packager.processing.workers.run_zip(job, cancel)[source]
Assemble and publish one zip on a background thread (SPEC §10); never raises.
Build at
ZipJob.build_path, publish toZipJob.final_pathvia.part+ atomic rename, then write the optional checksum sidecar. The build copy is removed whatever the outcome — after publishing on success (the build dir shrinks as bundles publish instead of holding every archive until run end), best-effort on failure or cancellation.- Parameters:
- Return type:
- Returns:
The publish outcome.