-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: replace FutureDriver
with tokio::spawn
#1080
Conversation
FutureDriver
with tokio::spawn
@@ -419,21 +356,19 @@ pub(crate) async fn background_task<L: Logger>( | |||
async fn send_task( | |||
rx: mpsc::Receiver<String>, | |||
mut ws_sender: Sender, | |||
stop_handle: StopHandle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, the stop handle was passed directly to send task and that stopped when it got the stop signal but it could be the case the pending calls were still in the queue and those were just canceled
so, I changed that we wait until those pending calls are finished and then stop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me offhand :)
// executed and the connection has been closed. | ||
tokio::select! { | ||
// All pending calls executed. | ||
_ = pending_calls.for_each(|_| async {}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we could also timeout out this after 10 minutes or something if someone has a infinite loop or something that never returns in some scenario it may "leak" and never terminate...
|
||
module | ||
.register_async_method("infinite_call", |_, _| async move { | ||
futures_util::future::pending::<()>().await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This a really bad and shouldn't be used in "real code" but just a way to ensure that the futures won't ever complete.
Close #1063