You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bdonlan opened this issue
Jul 1, 2020
· 2 comments
· Fixed by #2645
Labels
A-tokioArea: The main tokio crateC-bugCategory: This is a bug.I-crashProblems and improvements related to program crashes/panics.M-runtimeModule: tokio/runtime
When reproducing locally, here are the tokio crate versions:
│ │ │ ├── tokio v0.2.21
│ │ │ │ └── tokio-macros v0.2.5
│ │ │ └── tokio-util v0.3.1
│ │ │ └── tokio v0.2.21 (*)
│ │ ├── tokio v0.2.21 (*)
│ ├── tokio v0.2.21 (*)
└── tokio v0.2.21 (*)
Platform
64-bit linux, 5.4.30
Description
Often synchronous library APIs can be implemented in terms of a private tokio runtime. While it would be preferable to structure calls into these libraries as async calls, this isn't always possible, and so it should be possible to enter a blocking context using block_in_place and then block_on a different runtime. However, currently this fails:
running 1 test
test tokio_nesting ... FAILED
failures:
---- tokio_nesting stdout ----
thread 'tokio_nesting' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.', /playground/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/runtime/enter.rs:38:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
tokio_nesting
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
The text was updated successfully, but these errors were encountered:
To be specific, this fails because you are not doing it on a worker thread managed by the threaded runtime. If you add a spawn around the block_in_place, it works.
A fast path in block_on_place was failing to call exit() in the case where we
were in a block_on call.
Fixes: #2639
Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
A-tokioArea: The main tokio crateC-bugCategory: This is a bug.I-crashProblems and improvements related to program crashes/panics.M-runtimeModule: tokio/runtime
Version
Using tokio 0.2.21 on the playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3f63cb60db402855462f41a6980e719b
When reproducing locally, here are the tokio crate versions:
Platform
64-bit linux, 5.4.30
Description
Often synchronous library APIs can be implemented in terms of a private tokio runtime. While it would be preferable to structure calls into these libraries as async calls, this isn't always possible, and so it should be possible to enter a blocking context using
block_in_place
and thenblock_on
a different runtime. However, currently this fails:fails with:
The text was updated successfully, but these errors were encountered: