Skip to main content

periodic_rerun_sweep

The periodic-rerun sweep: which registered background tasks are due again.

A background DAG runs when its dataset is first linked to a project. This decides when to run it again: reading the cron calendar and the growth trigger, judging each due lineage against a series of gates, and handing the survivors to the BackgroundDAGHandler to schedule the same way any other background run is scheduled. On the same tick it also picks up a waved sweep that could not start yet, a budgeted refresh that has more slices to run, or a lineage that stood down until the pod's first EHR patient listing completed.

Separate from background_handler because the two answer different questions. That one owns how a background run happens and is shared by every trigger; this one owns whether a rerun should happen at all, which is a calendar, six gates and a Hub probe that nothing else needs. The pure policy (cron occurrences, due and growth predicates) lives in periodic_reruns; this module applies it. The only state it keeps is its own poller task and the once-per-occurrence log suppression; the cache stand-down lives on the handler, because recovery shares it.

On the same tick it reports the pod's own size — memory, threads, open files, the background cache's files — because a pod that stops for good leaves no precursor among its own events, and this is the last thing it says.

It reads the pod's identity and datasources off the PodContext, so it never imports bitfount.federated.pod.pod (pod already imports this package).

Classes​

PeriodicRerunSweep​

class PeriodicRerunSweep(    ctx: PodContext, *, scheduler: BackgroundScheduler, file_counter: IndexedFileCounter,):

Reruns healthy background lineages on a schedule and as they grow.

Schedules through the BackgroundScheduler it is given, opens the cache through it too (so the stand-down it shares with recovery applies), and asks the IndexedFileCounter how far a datasource has been indexed for the growth trigger.

Arguments

  • ctx: The pod's identity and services.
  • scheduler: Schedules a stored lineage and opens the background cache.
  • file_counter: Counts the files indexed for a lineage's datasource.

Methods​


start​

def start(self) ‑> None:

Start the periodic-rerun poller, unless disabled or already running.

Near-verbatim with BackgroundDAGHandler.start_recovery / BackgroundDAGHandler.stop_recovery.

stop​

async def stop(self) ‑> None:

Cancel the periodic-rerun poller and wait for it to unwind.