diff options
author | Eliza Weisman <eliza@buoyant.io> | 2018-09-18 21:57:21 -0700 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2018-09-18 21:57:21 -0700 |
commit | 98d23b8b29da90f174fc61c66a5b8cd9f91778e9 (patch) | |
tree | 4ac2b6db86fe36e644cac84e56f7957afd3712b3 /src | |
parent | 85f85225364b9f4d144076cbbdcdbd917da8fc7b (diff) |
Make `tokio::run` panic if called from inside `tokio::run` (#646)
This is implemented by creating an `Enter` instance from within `run`.
This patch also introduces `Enter::block_on`.
Fixes #504
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index c23d8dd1..9ff0cc4c 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -125,6 +125,7 @@ use reactor::{Background, Handle}; use std::io; +use tokio_executor::enter; use tokio_threadpool as threadpool; use futures; @@ -210,7 +211,9 @@ where F: Future<Item = (), Error = ()> + Send + 'static, { let mut runtime = Runtime::new().unwrap(); runtime.spawn(future); - runtime.shutdown_on_idle().wait().unwrap(); + enter().expect("nested tokio::run") + .block_on(runtime.shutdown_on_idle()) + .unwrap(); } impl Runtime { |