Skip to content

Commit 013a7db

Browse files
committed
retry_blocking does no longer spawn a blocking task
1 parent 2648aff commit 013a7db

File tree

1 file changed

+14
-18
lines changed
  • turbopack/crates/turbo-tasks-fs/src

1 file changed

+14
-18
lines changed

turbopack/crates/turbo-tasks-fs/src/retry.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{
22
io::{self, ErrorKind},
33
path::{Path, PathBuf},
4-
thread::sleep,
54
time::Duration,
65
};
76

@@ -12,25 +11,22 @@ where
1211
F: Fn(&Path) -> io::Result<R> + Send + 'static,
1312
R: Send + 'static,
1413
{
15-
turbo_tasks::spawn_blocking(move || {
16-
let mut attempt = 1;
14+
let mut attempt = 1;
1715

18-
loop {
19-
return match func(&path) {
20-
Ok(r) => Ok(r),
21-
Err(err) => {
22-
if attempt < MAX_RETRY_ATTEMPTS && can_retry(&err) {
23-
sleep(get_retry_wait_time(attempt));
24-
attempt += 1;
25-
continue;
26-
}
27-
28-
Err(err)
16+
loop {
17+
return match func(&path) {
18+
Ok(r) => Ok(r),
19+
Err(err) => {
20+
if attempt < MAX_RETRY_ATTEMPTS && can_retry(&err) {
21+
tokio::time::sleep(get_retry_wait_time(attempt)).await;
22+
attempt += 1;
23+
continue;
2924
}
30-
};
31-
}
32-
})
33-
.await
25+
26+
Err(err)
27+
}
28+
};
29+
}
3430
}
3531

3632
fn can_retry(err: &io::Error) -> bool {

0 commit comments

Comments
 (0)