Skip to content

Commit

Permalink
Throttle pty output messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mdepp committed Dec 3, 2023
1 parent 0cc350a commit ac3ad81
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use iced::{futures::channel::mpsc, subscription, Subscription};
use log::{debug, error, info};
use std::future::pending;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::time;
use tokio::{join, select};
use tokio_util::sync::CancellationToken;

Expand Down Expand Up @@ -86,6 +87,8 @@ async fn make_pty(
Ok(nbytes) => {
debug!("Read {nbytes} bytes from pty");
cloned_sender.send(OutputEvent::Stdout(readbuf[..nbytes].into())).await?;
// HACK: throttle pty output messages to avoid overwhelming iced
time::sleep(time::Duration::from_millis(10)).await;
}
Err(err) => {
error!("pty read error: {err}");
Expand Down

0 comments on commit ac3ad81

Please sign in to comment.