atomscale.timeseries to receive analysis updates as they arrive. Four entry points cover different concurrency needs:
| Function | Use case |
|---|---|
iter_poll | Synchronous loop that blocks between polls |
start_polling_thread | Background thread for GUI or acquisition loops |
aiter_poll | Async iterator for asyncio applications |
start_polling_task | Fire-and-forget asyncio task |
Setup
Synchronous polling
Loop overiter_poll to fetch fresh rows on a fixed cadence. The helper waits interval seconds between polls.
Parameters
| Parameter | Description |
|---|---|
interval | Seconds between polls (default: 1.0) |
last_n | Only fetch the last N rows (None for all) |
distinct_by | Function to extract a key for deduplication |
max_polls | Stop after this many polls |
fire_immediately | Poll immediately or wait one interval first (default: True) |
jitter | Random delay (0 to jitter) added to each sleep |
until | Predicate function; stop when it returns True |
on_error | Handler called when a poll fails |
Background thread polling
Usestart_polling_thread when you can’t block the main thread (GUI, acquisition loop):
threading.Event that you can set to stop polling gracefully.
Async polling
Two helpers integrate withasyncio:
Async iterator
aiter_poll yields results without blocking the event loop:
Background task
start_polling_task creates a background task that invokes an optional async handler:
Deduplication
Thedistinct_by parameter accepts a function that extracts a hashable key from each result. Only results with a new key are yielded, so you won’t process the same data twice when polling faster than updates arrive.