pynws
pynws copied to clipboard
Add more conditions for retries
It might be useful to have other conditions kick off retry attempts, e.g.
- [x] blank observations (e.g.
[]returned) - [x] blank forecasts being returned (see above)
- [ ] outdated observations being returned
- [x] outdated forecasts being returned
- [ ] detailed Forecasts
- [ ] all alerts updates. (Not useful?)
A problem with the current use of call_with_retry that wraps any update_* call is that is is harder to make special cases for update_observation for example.
One thought that I like is to have a new keyword arg for each update_* method that would raise an error when some condition is met for the data coming back from the update. We could use NWSError or subclass from it.
This would allow us to catch those specific errors in the retry, it also allows downstream codes to catch them.
Observations already allow a start_time parameter, right now we trust NWS to satisfy this request. We should also filter it if user supplies this and NWS returns old data.