Update tokio to 0.2 again and remove TaskExecutors (#786)

* upgrade tokio again

* Remove WrappedExecutor

* switch to spawn_blocking
This commit is contained in:
Ashley
2020-01-29 12:13:47 +01:00
committed by GitHub
parent aa86197ec9
commit 04eae615b5
14 changed files with 63 additions and 134 deletions
+1 -2
View File
@@ -11,7 +11,6 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
log = "0.4.8"
futures = { version = "0.3.1", features = ["compat"] }
futures01 = { package = "futures", version = "0.1.29" }
structopt = "=0.3.7"
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
@@ -23,7 +22,7 @@ sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polk
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "polkadot-service", path = "../service", default-features = false }
tokio = { version = "0.1.22", optional = true }
tokio = { version = "0.2.10", features = ["rt-threaded"], optional = true }
wasm-bindgen = { version = "0.2.57", optional = true }
wasm-bindgen-futures = { version = "0.4.7", optional = true }
+11 -25
View File
@@ -24,9 +24,7 @@ mod chain_spec;
mod browser;
use chain_spec::ChainSpec;
use futures::{
Future, FutureExt, TryFutureExt, future::select, channel::oneshot, compat::Compat,
};
use futures::{Future, future::{select, Either}, channel::oneshot};
#[cfg(feature = "cli")]
use tokio::runtime::Runtime;
use log::info;
@@ -35,7 +33,7 @@ use sp_api::ConstructRuntimeApi;
pub use service::{
AbstractService, CustomConfiguration, ProvideRuntimeApi, CoreApi, ParachainHost, IsKusama,
WrappedExecutor, Block, self, RuntimeApiCollection, TFullClient
Block, self, RuntimeApiCollection, TFullClient
};
pub use sc_cli::{VersionInfo, IntoExit, NoCustom, SharedParams};
@@ -172,8 +170,8 @@ where
config.custom.authority_discovery_enabled = custom_args.authority_discovery_enabled;
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
config.tasks_executor = {
let runtime_handle = runtime.executor();
Some(Box::new(move |fut| { runtime_handle.spawn(Compat::new(fut.map(Ok))); }))
let runtime_handle = runtime.handle().clone();
Some(Box::new(move |fut| { runtime_handle.spawn(fut); }))
};
match config.roles {
service::Roles::LIGHT =>
@@ -221,34 +219,22 @@ pub fn run_until_exit(
) -> error::Result<()> {
let (exit_send, exit) = oneshot::channel();
let executor = runtime.executor();
let informant = sc_cli::informant::build(&service);
let future = select(exit, informant)
.map(|_| Ok(()))
.compat();
executor.spawn(future);
let handle = runtime.spawn(select(exit, informant));
// we eagerly drop the service so that the internal exit future is fired,
// but we need to keep holding a reference to the global telemetry guard
let _telemetry = service.telemetry();
let service_res = {
let service = service
.map_err(|err| error::Error::Service(err));
let select = select(service, e)
.map(|_| Ok(()))
.compat();
runtime.block_on(select)
};
let service_res = runtime.block_on(select(service, e));
let _ = exit_send.send(());
use futures01::Future;
// TODO [andre]: timeout this future substrate/#1318
let _ = runtime.shutdown_on_idle().wait();
runtime.block_on(handle);
service_res
match service_res {
Either::Left((res, _)) => res.map_err(error::Error::Service),
Either::Right((_, _)) => Ok(())
}
}