tdfs4ds.serve.activity¶
tdfs4ds.serve.activity
¶
What the admin app is doing in the background, for the status bar (0.3.3.15).
A process-wide, thread-safe registry of jobs: each has a key, a label, an
optional done / total count and a one-line detail. Nothing here touches the
database. GET /ui/status reads snapshot().
Two ways in:
start(key, label)returns a handle that an existing worker updates (update) and closes (finish) -- used around the streamed panel jobs (maintenance, documentation, migration, evaluation, benchmark).run_in_background(key, label, fn)runsfn(handle)in a daemon thread. A job whose key is already running is not started twice: one re-run is queued and starts when the running one ends (two builds of one store's index at once would race on the same collections).
Finished jobs stay visible for KEEP_FINISHED_S seconds so the bar can say
"done" or show the error, whole.
Handle
¶
A job's handle: update while it runs, finish once.
run_in_background
¶
Run fn(handle) in a daemon thread under key.
Returns 'started', or 'queued' when a job with the same key is
running (one re-run then follows it; queueing again replaces the waiting
one, which is the same work).
snapshot
¶
Running jobs (oldest first) then jobs finished in the last KEEP_FINISHED_S
seconds (newest first). Older finished jobs are dropped.