keeptabs.engine#
The scheduled run: work out what is due, acquire it, match it, store it.
tick() is idempotent and safe to call as often as you like. Whether a source
is due is computed from stored state, so any trigger works (cron, launchd, a
systemd timer, a loop) and a missed run is simply caught up by the next one.
Functions
|
The sources of a spec that should be fetched now. |
|
Fetch one source and store what is new. |
|
Whether a source (or a digest) with this stored state should run now. |
|
The sources of a spec that are enabled and wait on no human action. |
|
The key of a source's record in the |
|
Run everything that is due, once, and say what happened. |
|
Hold the local lock that keeps two ticks from running at once. |
Exceptions
Another tick holds the lock. |
- exception keeptabs.engine.AlreadyRunning[source]#
Bases:
RuntimeErrorAnother tick holds the lock.
- keeptabs.engine.due_sources(spec, state_store, *, now=None)[source]#
The sources of a spec that should be fetched now.
- Return type:
- keeptabs.engine.fetch_source(spec, source, mall, *, fetchers, http_get, matcher, now)[source]#
Fetch one source and store what is new. Returns the run record.
It never raises for a failing source: the failure is recorded, the source backs off, and the caller carries on.
- Return type:
- keeptabs.engine.is_due(state, *, now)[source]#
Whether a source (or a digest) with this stored state should run now.
>>> now = to_datetime('2026-01-02') >>> is_due({}, now=now), is_due({'next_due': '2026-01-03T00:00:00+00:00'}, now=now) (True, False)
- Return type:
- keeptabs.engine.runnable_sources(spec)[source]#
The sources of a spec that are enabled and wait on no human action.
- Return type:
- keeptabs.engine.state_key(source)[source]#
The key of a source’s record in the
statestore.- Return type:
- keeptabs.engine.tick(watch_ids=None, *, rootdir=None, specs=None, malls=None, fetchers=None, http_get=None, matcher=None, on_digest_due=None, lock=None, now=None, force=False)[source]#
Run everything that is due, once, and say what happened.
specs: the store of watch specifications (default: local files underrootdir).malls: a function from a watch id to that watch’s stores (default: local files). Stores of your own come in a pair: give bothspecsandmalls.fetchers: source kind to fetcher, added to the defaults.http_get: the one door to the network.matcher:match(item, spec, *, mall), scoring an item against a spec.on_digest_due: called with(spec, mall, now)for each watch whose digest is due (default:keeptabs.digest.scheduled_digest());Falsefor no digest.lock: a context manager held for the run, orFalsefor none. The default is a local file lock, and none when the stores are your own.force: run every enabled, unblocked source whatever its schedule.
A watch or a source that fails is reported in
failuresand does not stop the rest.- Return type: