mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Better joining of session tasks
This commit is contained in:
parent
f158d230d1
commit
4c2fc61d64
1 changed files with 9 additions and 4 deletions
|
@ -10,7 +10,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::TryStream;
|
use futures_core::TryStream;
|
||||||
use futures_util::{FutureExt, StreamExt, TryStreamExt};
|
use futures_util::{future, StreamExt, TryStreamExt};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
@ -126,9 +126,14 @@ impl Session {
|
||||||
.forward(sink);
|
.forward(sink);
|
||||||
let receiver_task = DispatchTask(stream, session.weak());
|
let receiver_task = DispatchTask(stream, session.weak());
|
||||||
|
|
||||||
let task =
|
tokio::spawn(async move {
|
||||||
futures_util::future::join(sender_task, receiver_task).map(|_| io::Result::<_>::Ok(()));
|
let result = future::try_join(sender_task, receiver_task).await;
|
||||||
tokio::spawn(task);
|
|
||||||
|
if let Err(e) = result {
|
||||||
|
error!("{}", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
session
|
session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue