more robust data fetching
This commit is contained in:
parent
1dc0c9c0e1
commit
ce8a095b31
@ -14,8 +14,12 @@ pub fn schedule(db: &SqlitePool, config: &Config) {
|
|||||||
let openweathermap_key = config.openweathermap_key.clone();
|
let openweathermap_key = config.openweathermap_key.clone();
|
||||||
|
|
||||||
tokio::task::spawn(async {
|
tokio::task::spawn(async {
|
||||||
waterlevel::update(&db).await.unwrap();
|
if let Err(e) = waterlevel::update(&db).await {
|
||||||
weather::update(&db, &openweathermap_key).await.unwrap();
|
log::error!("Water level update error: {e}, trying again next time");
|
||||||
|
}
|
||||||
|
if let Err(e) = weather::update(&db, &openweathermap_key).await {
|
||||||
|
log::error!("Weather update error: {e}, trying again next time");
|
||||||
|
}
|
||||||
|
|
||||||
let mut sched = JobScheduler::new();
|
let mut sched = JobScheduler::new();
|
||||||
|
|
||||||
@ -26,10 +30,12 @@ pub fn schedule(db: &SqlitePool, config: &Config) {
|
|||||||
// nicer one's rust (stable) support async closures
|
// nicer one's rust (stable) support async closures
|
||||||
task::block_in_place(|| {
|
task::block_in_place(|| {
|
||||||
tokio::runtime::Handle::current().block_on(async {
|
tokio::runtime::Handle::current().block_on(async {
|
||||||
waterlevel::update(&db_clone).await.unwrap();
|
if let Err(e) = waterlevel::update(&db_clone).await {
|
||||||
weather::update(&db_clone, &openweathermap_key)
|
log::error!("Water level update error: {e}, trying again next time");
|
||||||
.await
|
}
|
||||||
.unwrap();
|
if let Err(e) = weather::update(&db_clone, &openweathermap_key).await {
|
||||||
|
log::error!("Weather update error: {e}, trying again next time");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user