-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
tokio::fs::File::open errors with "blocking
annotated I/O must be called from the context of the Tokio runtime."
#1356
Comments
Could you include the list of crates you got pulled in (including deps). Odds are you are mixing git deps & crates.io deps. |
[dependencies]
tokio = { git = "https://github.com/tokio-rs/tokio" } From my [[package]]
name = "tokio"
version = "0.2.0"
source = "git+https://github.com/tokio-rs/tokio#298be802492068d28b972069c5f654de124fd510"
dependencies = [
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-codec 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-current-thread 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-executor 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-fs 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-macros 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-reactor 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-sync 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-tcp 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-timer 0.3.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-udp 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-uds 0.3.0 (git+https://github.com/tokio-rs/tokio)",
"tracing-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
] [[package]]
name = "tokio-fs"
version = "0.2.0"
source = "git+https://github.com/tokio-rs/tokio#298be802492068d28b972069c5f654de124fd510"
dependencies = [
"futures-core-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.2.0 (git+https://github.com/tokio-rs/tokio)",
"tokio-threadpool 0.2.0 (git+https://github.com/tokio-rs/tokio)",
] |
Would just like to note that the issue doesn't seem to be platform-dependent. 0 proximyst@proximyst-arch:~/tokio_test|HEAD⚡?
λ cargo run
Compiling tokio_test v0.1.0 (/home/proximyst/tokio_test)
Finished dev [unoptimized + debuginfo] target(s) in 0.82s
Running `target/debug/tokio_test`
Error: Custom { kind: Other, error: "`blocking` annotated I/O must be called from the context of the Tokio runtime." }
1 proximyst@proximyst-arch:~/tokio_test|HEAD⚡?
λ uname -a
Linux proximyst-arch 5.1.16-arch1-1-ARCH #1 SMP PREEMPT Wed Jul 3 20:23:07 UTC 2019 x86_64 GNU/Linux The code is simply the minimal reproduction example. |
Ah! Ok, I see the problem... This is due to #1329... I'm not sure what the best short term fix... the longer term fix is to finish a bunch of planned work... |
I hit this same issue, but with fn main() -> Result<(), Box<dyn std::error::Error>> {
run(async {
File::open("Cargo.toml").await?;
Ok(())
})
}
fn run<F>(f: F) -> F::Output
where
F: Future + Send + 'static,
F::Output: Send + Debug,
{
let (tx, rx) = tokio::sync::oneshot::channel();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.spawn(async move {
tx.send(f.await).unwrap();
});
rt.block_on(rx).unwrap()
} |
The #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stdin = tokio::io::stdin();
let mut s = String::new();
stdin.read_to_string(&mut s).await?;
Ok(())
} |
… operations. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
Fixed by #1329. |
Whoops you are right. Copy / paste fail |
… operations. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
of futures-rs executor. Despite this change, using body_bytes_wait on (for example) a File will still fail due to tokio-rs/tokio#1356.
Version
Git master branch
Platform
64-bit Windows 10
Subcrates
tokio-fs
Description
Minimal reproduction:
This will error with
even when using the default multithreaded runtime. Manually starting the runtime doesn't seem to work either.
The text was updated successfully, but these errors were encountered: