cellmap_flow.dashboard.progress
How far a long request has got, for the page to poll while it waits.
Importing crops from a YAML and resuming a session each take one request
that can run for minutes. The page sends a load_id with it and polls a
progress route with the same id meanwhile; the request records each step
under that id as it goes.
Classes
The latest progress of each request in flight, by its |
Module Contents
- class cellmap_flow.dashboard.progress.Progress(ttl_seconds=300)
The latest progress of each request in flight, by its
load_id.A request’s entry is a dict of what it last reported (its
phase,doneand whatever counts it keeps), pluscreated_atandupdated_atin epoch seconds. An entry not updated forttl_secondsis dropped, so the entries of loads nobody polls any more do not pile up. Request threads update and read it concurrently.- update(load_id, **fields)
Merge
fieldsintoload_id’s entry; without an id, nothing.
- response(load_id)
A progress route’s answer:
{"success": True, "progress": <entry>}; a 400 without aload_id, and a 404 for one it has no entry for.