I want to add progress bar to my function (just async function to POST to a website)
let client = reqwest::Client::builder()
.default_headers(headers)
.build()?;
...
let post_resp = client
.post(encoded)
.headers(headers)
.body(body_data)
.send()
.await?;
so If I increase my progress bar when making post data but they don't take much time only this post will block updating ETA time in the progress bar and quickly ends.
What I want to do is to make the progress bar more smoother overall (so far I tried like this
progress_bar.inc(30); // +30%
tokio::time::sleep(Duration::from_millis(12)).await; // artificial delay
I also thought about spawning background thread to update but idk what's best value for POST as i have to wait that loop to finish even thought POST is done.
let progress_task = tokio::spawn(async move {
let mut i = 0;
let mut intv = tokio::time::interval(Duration::from_millis(10));
// Loop until progress is complete
while i < 100 {
intv.tick().await;
i += 1;
// cloned.set_position(i);
cloned.inc(1);
}
});