archivebox.services.archive_result_service

Module Contents

Classes

ArchiveResultService

Project abx-dl ArchiveResult facts into Django models.

Functions

_perf_trace

_perf_span

_manifest_metadata

_resolve_output_metadata

_normalize_status

_normalize_snapshot_title

_extract_snapshot_title

_should_update_snapshot_title

_save_archiveresult_event_to_db

Project one ArchiveResultEvent with a single thread-sensitive ORM hop.

mark_archiveresult_started

Project a running abx-dl hook after its OS process is persisted.

API

archivebox.services.archive_result_service._perf_trace(label)[source]
archivebox.services.archive_result_service._perf_span(label: str)[source]
archivebox.services.archive_result_service._manifest_metadata(manifest: abx_dl.output_files.OutputManifest) → tuple[dict[str, dict], int, str][source]
archivebox.services.archive_result_service._resolve_output_metadata(raw_output_files: Any, plugin_dir: pathlib.Path) → tuple[dict[str, dict], int, str][source]
archivebox.services.archive_result_service._normalize_status(status: str) → str[source]
archivebox.services.archive_result_service._normalize_snapshot_title(candidate: str, *, snapshot_url: str) → str[source]
archivebox.services.archive_result_service._extract_snapshot_title(snapshot_output_dir: str, plugin: str, output_str: str, *, snapshot_url: str) → str[source]
archivebox.services.archive_result_service._should_update_snapshot_title(current_title: str, next_title: str, *, snapshot_url: str) → bool[source]
archivebox.services.archive_result_service._save_archiveresult_event_to_db(event: abx_dl.events.ArchiveResultEvent, process_started: abx_dl.events.ProcessStartedEvent | None) → None[source]

Project one ArchiveResultEvent with a single thread-sensitive ORM hop.

Django’s async ORM still delegates each query to sync Django work. The hot search/index maintenance path was paying that handoff separately for Snapshot lookup, Process lookup, ArchiveResult lookup, update, and title checks. Keep the public ArchiveResultEvent path intact, but run the DB projection as one short synchronous block so SQLite sees the same indexed reads/writes without per-query asyncio/threadpool churn.

archivebox.services.archive_result_service.mark_archiveresult_started(event: abx_dl.events.ProcessStartedEvent, *, snapshot_id: str, process_id: str) → None[source]

Project a running abx-dl hook after its OS process is persisted.

This DB state records process execution; the scheduler separately waits for stdout readiness before advancing past a background hook. Neither boundary proves that an archive was produced. Final status comes from the owning hook’s ArchiveResultEvent, including corrections after an abnormal exit. Rows are per snapshot/plugin/hook: a recorder’s start hook cannot declare that its separate export hook succeeded.

class archivebox.services.archive_result_service.ArchiveResultService(bus)[source]

Bases: abx_dl.services.base.BaseService

Project abx-dl ArchiveResult facts into Django models.

Initialization

LISTENS_TO[source]

None

EMITS[source]

[]

async on_ArchiveResultEvent__save_to_db(event: abx_dl.events.ArchiveResultEvent) → None[source]