Bookkeeping Suspension Mechanism (processinginterface.py)
This document explains how to pause processing of a publication for a defined time window using the bookkeeping job API.
What suspension does
When a job is returned, its location receives a wdmvoc:suspendedUntil timestamp in the graph.
Job selection through obtain_jobs(...) excludes suspended locations by default:
ignore_suspension=False(default): skip locations whilesuspendedUntil > NOW().ignore_suspension=True: return suspended locations even before their suspension expires.
Filtering happens in BookkeepingHandler.identify_module_job_locations(...). The timestamp is written by log_only_temp_processing_attempt(...) for a temporary-only outcome or update_processing_files_info_and_reassign(...) for a normal or stop outcome.
Mandatory suspension period
To avoid module interference if modules run parallelly, each publication receives a two minutes mandatory suspension upon job return (unless a longer suspension period is requested by the module returning the job).
End-date requirement
suspend_until is optional. When provided, it must be a timezone-aware datetime; UTC is recommended. Naive datetimes are rejected. Passing None just assigns the mandatory suspension period mentioned above.
Use the helpers in utils.py to create valid UTC timestamps:
import utils
# Next occurrence of day 1 or 15, whichever is first.
suspend_until = utils.suspension_end_date_by_day_in_month([1, 15])
# Three days from now.
suspend_until = utils.suspension_end_date_by_number_of_days(3)
Returning a normal job
from utils import suspension_end_date_by_number_of_days
suspend_until = suspension_end_date_by_number_of_days(2)
pi.return_job(
job=job,
temp_dir=temp_dir_name,
processed_dir=processed_dir_name,
created_files=created_files,
modified_files=modified_files,
deleted_files=deleted_files,
suspend_until=suspend_until,
)
Returning a startup job
from utils import suspension_end_date_by_day_in_month
suspend_until = suspension_end_date_by_day_in_month([1, 15])
pi.return_startup_job(
job=job,
article_dir=article_dir,
temp_dir=temp_dir_name,
processed_dir=processed_dir_name,
created_files=created_files,
modified_files=modified_files,
deleted_files=deleted_files,
suspend_until=suspend_until,
)
Caching a startup-job return
from utils import suspension_end_date_by_number_of_days
suspend_until = suspension_end_date_by_number_of_days(1)
pi.return_startup_job_cached(
job=job,
article_dir=article_dir,
temp_dir=temp_dir_name,
processed_dir=processed_dir_name,
created_files=created_files,
modified_files=modified_files,
deleted_files=deleted_files,
suspend_until=suspend_until,
)
The cached timestamp is serialized into the startup-job recovery data and restored when the cache is processed or rescued.
Processing suspended jobs early
No manual unsuspend step is required. A job automatically becomes eligible when its suspension timestamp is in the past. To process it before expiry:
for job in pi.obtain_jobs(ignore_suspension=True):
...
Please use the ignore_suspension functionality cautiously when executing modules in parallel: It will also cause the mandatory two minutes suspension to be ignored.
Practical guidance
- Use
suspension_end_date_by_number_of_days(...)for retry and backoff windows. - Use
suspension_end_date_by_day_in_month(...)for fixed monthly windows. - Keep suspensions bounded rather than indefinite.
- Prefer UTC to avoid timezone and daylight-saving ambiguity.
- Pass
suspend_untilonly for jobs that should be paused.