Overview
The platform includes two specialized schedulers for different data collection patterns:- snoozerScheduler: Urgency-based scheduling for live, high-frequency data (priceoverview, histogram, activity)
- ClockworkScheduler: Fixed-interval scheduling for historical price data (pricehistory)
snoozerScheduler
Urgency-based scheduler for real-time market data with dynamic prioritization.Class Definition
Constructor
Optional list of items to track. If None, loads from config.
Optional shared RateLimiter instance. If None, client creates its own.
Path to YAML configuration file (used if live_items is None)
Attributes
List of item configurations to track
Rate limiter instance for API call throttling
Steam API client (initialized in run())
Database writer (initialized in run())
Methods
load_live_items()
Load all items from config that are NOT pricehistory.List of live item configurations (priceoverview, histogram, activity)
calculate_urgency()
Calculate urgency score for an item.Item configuration with last_update and polling-interval-in-seconds
Urgency score:
>= 1.0: Overdue, needs immediate execution< 1.0: Not yet due0.0: In cooldown periodinf: Never updated (highest priority)
calculate_min_sleep_duration()
Calculate minimum sleep time until ANY item becomes actionable.Sleep duration in seconds until soonest item needs execution
- Reaches urgency 1.0 (overdue), OR
- Exits 429 cooldown (skip_until reached)
apply_exponential_backoff()
Apply exponential backoff for rate limit (429), server (5xx), or network errors.Item configuration that received the error
HTTP status code (429, 5xx) or 0 for network errors
- 1st error: skip 1 polling interval
- 2nd consecutive: skip 2 intervals
- 3rd consecutive: skip 4 intervals
- Capped at 8x the polling interval
execute_item()
Execute the API call for a specific item.Item configuration to execute
- Check if item is in cooldown (skip if so)
- Execute appropriate API call based on
apiid - Store result to database
- Update
last_updatetimestamp - Reset backoff tracking on success
- Apply exponential backoff on errors
run()
Main scheduler loop using urgency-based algorithm.- Calculate urgency for all items
- Execute ALL items with urgency >= 1.0
- If nothing was urgent, sleep until next item becomes urgent
- Repeat forever
ClockworkScheduler
Fixed-interval scheduler for historical price data collection.Class Definition
Constructor
Optional list of pricehistory items to track. If None, loads from config.
Optional shared RateLimiter instance. If None, client creates its own.
Path to YAML configuration file (used if items is None)
Attributes
List of pricehistory item configurations
Rate limiter instance for API call throttling
Steam API client (initialized in run())
Database writer (initialized in run())
Methods
get_next_execution_time()
Calculate the next execution time (:30 past the next hour).Next execution time (next hour at :30 UTC)
calculate_sleep_duration()
Calculate seconds to sleep until next execution.Target execution datetime
Sleep duration in seconds
execute_history_items()
Execute pricehistory API calls for all configured items.run_initial_fetch()
Run pricehistory once immediately when scheduler starts.run()
Main clockwork loop.- Run pricehistory immediately on startup
- Calculate next :30 past the hour
- Sleep until that time
- Execute all pricehistory items
- Repeat from step 2
- 00:30, 01:30, 02:30, …, 23:30
Comparison
| Feature | snoozerScheduler | ClockworkScheduler |
|---|---|---|
| Use Case | Live data (priceoverview, histogram, activity) | Historical data (pricehistory) |
| Algorithm | Urgency-based (dynamic priority) | Fixed-time (hourly at :30) |
| Scheduling | Calculated per-item based on polling interval | Fixed: :30 past every UTC hour |
| Priority | Most overdue item first | All items equal |
| Backoff | Per-item exponential backoff | Global retry with backoff |
| Initial Run | Immediate (all items fire at startup) | Immediate (then hourly) |
| Sleep Logic | Until next item overdue | Until next :30 past hour |
Error Handling
Both schedulers handle errors gracefully:Transient Errors (429, 5xx, network)
- snoozerScheduler: Exponential backoff per item (cooldown period)
- ClockworkScheduler: Retry with fixed backoff (30s, 60s, 120s, 240s)
Authentication Errors (400, 401, 403)
- snoozerScheduler: Log error, continue with other items
- ClockworkScheduler: Retry with backoff (supports hot-swapping cookies)
Client Errors (other 4xx)
- Log error, no retry (configuration issue)
Validation Errors
- Log error, no retry (data structure mismatch)
Best Practices
- Share Rate Limiter: Always pass the same rate limiter instance to both schedulers via Orchestrator
-
Configure Polling Intervals: Set intervals based on data freshness needs:
- Price overview: 30-60s
- Order histogram: 60-120s
- Order activity: 30-60s
- Price history: Ignored (fixed hourly)
- Monitor Urgency: Items with urgency consistently > 2.0 indicate underprovisioned rate limits
-
Handle Backoff: Don’t manually override
skip_until- let the scheduler manage cooldowns - Use Orchestrator: Don’t instantiate schedulers directly in production - use Orchestrator for proper coordination