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
Tokio::runtime::Runtime::block_on does not work as expected. For my use case it would be great if it could be used similarly to tokio::run. I am replacing tokio::run in order to allow the entire runtime to shutdown gracefully if a panic occurs in a spawned future.
I tried this
runtime.block_on(future::lazy(|| main()))
which returned: error on unwrap: 'Value: Canceled' suggesting that the oneshot sender created in block_on was getting dropped early. I also saw SpawnError {shutdown: is_true} during development.
I eventually was successful by using tokio_executor::with_default() to set the executor as the default for the runtime context. I then experienced similar errors for timer when I tried to implement a timeout(); this required the same solution, tokio_timer::with_default(). In the end I am not using runtime::block_on directly instead using tokio_executor::Enter::block_on() within the context of default reactor, executor, and timer that I set up.
It would be great to have something similar to block_on that sets these defaults, or a way to easily create the defaults through the runtime rather then bringing in tokio_executor, tokio_reactor, and tokio_timer for access to their with_default methods...or some clear documentation in block_on hinting at the lack of defaults and where that could cause problems within the runtime context.
Sample runtime context setup with defaults for ::block_on
The text was updated successfully, but these errors were encountered:
fordN
changed the title
Difficulty using runtime::Runtime::block_on()
Errors because runtime::Runtime::block_on() does not set reactor, executor, or timer defaults
Oct 30, 2018
fordN
changed the title
Errors because runtime::Runtime::block_on() does not set reactor, executor, or timer defaults
Errors because runtime::Runtime::block_on() does not set reactor, executor, or timer defaults for the context
Oct 30, 2018
Version
Platform
Darwin Kernel Version 16.7.0: Thu Jun 21 20:07:39 PDT 2018; root:xnu-3789.73.14~1/RELEASE_X86_64 x86_64
Subcrates
Description
Tokio::runtime::Runtime::block_on does not work as expected. For my use case it would be great if it could be used similarly to
tokio::run
. I am replacing tokio::run in order to allow the entire runtime to shutdown gracefully if a panic occurs in a spawned future.I tried this
which returned:
error on unwrap: 'Value: Canceled'
suggesting that the oneshot sender created inblock_on
was getting dropped early. I also sawSpawnError {shutdown: is_true}
during development.I eventually was successful by using
tokio_executor::with_default()
to set the executor as the default for the runtime context. I then experienced similar errors for timer when I tried to implement atimeout()
; this required the same solution,tokio_timer::with_default()
. In the end I am not usingruntime::block_on
directly instead usingtokio_executor::Enter::block_on()
within the context of default reactor, executor, and timer that I set up.It would be great to have something similar to block_on that sets these defaults, or a way to easily create the defaults through the runtime rather then bringing in tokio_executor, tokio_reactor, and tokio_timer for access to their
with_default
methods...or some clear documentation inblock_on
hinting at the lack of defaults and where that could cause problems within the runtime context.Sample runtime context setup with defaults for
::block_on
https://github.com/graphprotocol/graph-node/blob/ford/tokio-blockon/node/src/main.rs#L67
The text was updated successfully, but these errors were encountered: