Foundation shared by every process: the task/UPID model and helpers
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-14 09:00:00 +02:00
debian Initial import 2026-09-14 09:00:00 +02:00
src/pmx_cork_tasks Initial import 2026-09-14 09:00:00 +02:00
tests Initial import 2026-09-14 09:00:00 +02:00
.gitignore Initial import 2026-09-14 09:00:00 +02:00
LICENSE Initial import 2026-09-14 09:00:00 +02:00
pyproject.toml Initial import 2026-09-14 09:00:00 +02:00
README.md Initial import 2026-09-14 09:00:00 +02:00

pmx-cork-tasks

The foundation every pmx-cork process shares, below the HTTP layer. It is the counterpart of libpve-common-perl minus the schema and route-handling halves, which live in pmx-cork-sdk.

Module Contents
tasks the task and UPID model after PVE::RESTEnvironment::fork_worker: detached worker processes, one directory per task with status.json and log, the listing and filtering the task API serves, reaping and retention
tools the PVE::Tools and PVE::File ports: run_command, file_get_contents, the crash-safe file_set_contents, lock_file, split_list, nodename (after PVE::INotify::nodename), plus the shared grammars NODE_NAME_RE and PATH_TEMPLATE_PATTERN and the absolute paths of systemctl and journalctl
logging_setup journald logging for the services, with a stderr fallback where python3-systemd is absent

No HTTP stack

The package has no runtime dependency. It imports neither starlette nor aiohttp nor uvicorn, and the test suite pins that. Command-line tooling can therefore read task state without loading a web stack. python3-systemd is recommended for journald logging.

The worker is registered, not named

tasks spawns detached workers but does not know which program runs them. Whatever process spawns tasks calls tasks.set_worker_command(argv) at boot. The foundation never refers to an upper layer; the dependency arrow points up only.

pmxcfs

file_set_contents is written with /etc/pve in mind: its temp file carries the writer's pid, the create is retried because pmxcfs does not make O_EXCL atomic, and perm=None skips the chmod that pmxcfs refuses. file_get_contents refuses a file above max_size with an OSError (EFBIG), so a caller that treats "unreadable" as one condition catches one exception family.

Tests

python3 -m pytest

Ships as python3-pmx-cork-tasks.