Skip to main content

Module worker_loop

Module worker_loop 

Source
Expand description

The loop both credit registration workers run.

The processes differ only in which phases they own and how often they look, so the scheduling lives here instead of in each of them.

Constantsยง

STILL_RUNNING_MESSAGE_TICKS ๐Ÿ”’
Ten minutes of ticks. The per-phase heartbeat in the database is the machine-readable half.
TICK_INTERVAL ๐Ÿ”’
How often each phaseโ€™s loop looks whether it is due; each phaseโ€™s own interval lives in credit_registration_phase_state.

Staticsยง

LAST_LOGGED_SKIP ๐Ÿ”’
The skip reason last logged for a phase, so a paused phase or an open breaker logs once per state change instead of on every tick until it clears.

Functionsยง

cancel_on_termination_signal ๐Ÿ”’
Kubernetes sends SIGTERM and waits terminationGracePeriodSeconds before killing the pod.
clear_skip_state ๐Ÿ”’
is_due ๐Ÿ”’
A phase is due when an admin asked for it, or when its interval has elapsed since it last began.
log_failure ๐Ÿ”’
log_skip_if_changed ๐Ÿ”’
run
Runs the phases process owns until SIGTERM or Ctrl-C. Each phase loops on its own, so an hour-long call in one does not hold up the others. On shutdown no phase starts another iteration, and the function returns once the iterations already running have finished.
run_due_phase ๐Ÿ”’
Runs one due phase, and schedules the next run.
run_if_due ๐Ÿ”’
run_phase_loop ๐Ÿ”’