-
-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
FsLoader makes blocking function calls like std::fs::File::open(), buf_reader.read_to_string() etc. in async block. This will lead to starvation of async runtime, and also probable panics.
Lines 110 to 130 in 27c0a80
| async move { | |
| match self.filepath(vocabulary, &url) { | |
| Some(filepath) => { | |
| let file = File::open(filepath).map_err(Error::IO)?; | |
| let mut buf_reader = BufReader::new(file); | |
| let mut contents = String::new(); | |
| buf_reader | |
| .read_to_string(&mut contents) | |
| .map_err(Error::IO)?; | |
| let doc = (*self.parser)(vocabulary, &url, contents.as_str()) | |
| .map_err(Error::Parse)?; | |
| Ok(RemoteDocument::new( | |
| Some(url), | |
| Some("application/ld+json".parse().unwrap()), | |
| doc, | |
| )) | |
| } | |
| None => Err(Error::NoMountPoint), | |
| } | |
| } | |
| .boxed() |
Expected behaviour:
Should use non blocking async functions, like those in tokio::fs instead.
Metadata
Metadata
Assignees
Labels
No labels