Skip to content

Commit

Permalink
Merge pull request #192 from tottoto/async-runtime
Browse files Browse the repository at this point in the history
Use tokio runtime uniformly
  • Loading branch information
lipanski committed Feb 23, 2024
2 parents 5aac55a + 39a27eb commit 8c37737
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ appveyor = { repository = "lipanski/mockito", branch = "master", service = "gith
[dependencies]
assert-json-diff = "2.0"
colored = { version = "~2.0", optional = true }
futures = "0.3"
futures-core = "0.3"
hyper = { version = "0.14", features = ["http1", "http2", "server", "stream"] }
log = "0.4"
rand = "0.8"
Expand All @@ -33,6 +33,7 @@ tokio = { version = "1.25", features = ["net", "rt", "sync"] }
[dev-dependencies]
env_logger = "0.8"
testing_logger = "0.1"
futures = { version = "0.3", default-features = false, features = ["alloc", "async-await"] }
reqwest = "0.11"
tokio = { version = "1.25", features = ["macros", "rt-multi-thread"] }

Expand Down
2 changes: 1 addition & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::error::Error;
use crate::Request;
use futures::stream::Stream;
use futures_core::stream::Stream;
use hyper::HeaderMap;
use hyper::StatusCode;
use std::fmt;
Expand Down
6 changes: 5 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ impl Server {
///
#[track_caller]
pub(crate) fn try_new() -> Result<ServerGuard, Error> {
futures::executor::block_on(async { Server::try_new_async().await })
runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Cannot build local tokio runtime")
.block_on(async { Server::try_new_async().await })
}

///
Expand Down

0 comments on commit 8c37737

Please sign in to comment.