1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

fix: do not panic on full channels

This commit is contained in:
Jake Stanger 2024-01-29 23:30:25 +00:00
parent cc39896181
commit 061663392e
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -62,8 +62,17 @@ macro_rules! glib_recv {
glib::spawn_future_local(async move {
// re-delcare in case ie `context.subscribe()` is passed directly
let mut rx = $rx;
while let Ok($val) = rx.recv().await {
$expr
loop {
match rx.recv().await {
Ok($val) => $expr,
Err(tokio::sync::broadcast::error::RecvError::Lagged(count)) => {
tracing::warn!("Channel lagged behind by {count}, this may result in unexpected or broken behaviour");
}
Err(err) => {
tracing::error!("{err:?}");
break;
}
}
}
});
}};