Improve tokio task execution (#1181)
* Add logging on shutdown * Replace tokio::spawn with handle.spawn * Upgrade tokio * Add a task executor * Beacon chain tasks use task executor * Validator client tasks use task executor * Rename runtime_handle to executor * Add duration histograms; minor fixes * Cleanup * Fix logs * Fix tests * Remove random file * Get enr dependency instead of libp2p * Address some review comments * Libp2p takes a TaskExecutor * Ugly fix libp2p tests * Move TaskExecutor to own file * Upgrade Dockerfile rust version * Minor fixes * Revert "Ugly fix libp2p tests" This reverts commit 58d4bb690f52de28d893943b7504d2d0c6621429. * Pretty fix libp2p tests * Add spawn_without_exit; change Counter to Gauge * Tidy * Move log from RuntimeContext to TaskExecutor * Fix errors * Replace histogram with int_gauge for async tasks * Fix todo * Fix memory leak in test by exiting all spawned tasks at the end
This commit is contained in:
@@ -6,7 +6,6 @@ edition = "2018"
|
||||
|
||||
[dev-dependencies]
|
||||
eth1_test_rig = { path = "../../testing/eth1_test_rig" }
|
||||
environment = { path = "../../lighthouse/environment" }
|
||||
toml = "0.5.6"
|
||||
web3 = "0.11.0"
|
||||
sloggers = "1.0.0"
|
||||
@@ -25,8 +24,9 @@ tree_hash = "0.1.0"
|
||||
eth2_hashing = "0.1.0"
|
||||
parking_lot = "0.10.2"
|
||||
slog = "2.5.2"
|
||||
tokio = { version = "0.2.20", features = ["full"] }
|
||||
tokio = { version = "0.2.21", features = ["full"] }
|
||||
state_processing = { path = "../../consensus/state_processing" }
|
||||
libflate = "1.0.0"
|
||||
lighthouse_metrics = { path = "../../common/lighthouse_metrics"}
|
||||
lazy_static = "1.4.0"
|
||||
environment = { path = "../../lighthouse/environment" }
|
||||
|
||||
@@ -290,7 +290,7 @@ impl Service {
|
||||
/// - Err(_) if there is an error.
|
||||
///
|
||||
/// Emits logs for debugging and errors.
|
||||
pub fn auto_update(service: Self, exit: tokio::sync::oneshot::Receiver<()>) {
|
||||
pub fn auto_update(service: Self, handle: environment::TaskExecutor) {
|
||||
let update_interval = Duration::from_millis(service.config().auto_update_interval_millis);
|
||||
|
||||
let mut interval = interval_at(Instant::now(), update_interval);
|
||||
@@ -303,9 +303,7 @@ impl Service {
|
||||
}
|
||||
};
|
||||
|
||||
let future = futures::future::select(Box::pin(update_future), exit);
|
||||
|
||||
tokio::task::spawn(future);
|
||||
handle.spawn(update_future, "eth1");
|
||||
}
|
||||
|
||||
async fn do_update(service: Self, update_interval: Duration) -> Result<(), ()> {
|
||||
|
||||
Reference in New Issue
Block a user