-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
My library uses a global Client to run its requests.
The following code:
#[cfg(test)]
mod tests {
use hyper::{
client::{Client, HttpConnector},
Body, Request,
};
lazy_static::lazy_static! {
static ref CLIENT: Client<HttpConnector, Body> = Client::new();
}
async fn req(uri: &str) {
CLIENT
.request(Request::builder().uri(uri).body(Body::from("")).unwrap())
.await
.unwrap();
}
macro_rules! tests {
($($name:ident)*) => {
$(
#[tokio::test]
async fn $name() {
req("http://example.org/").await;
}
)*
};
}
tests!(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10);
}With tokio 0.2.9, hyper 0.13.1 and lazy_static 1.4.0, generates 10 tests, t1-t10, with each one making a simple request using a global client. Every cargo test, a random number of them panic with this backtrace.
This has been reported before, but was closed by the author.
The error seems to be that I am using the same Client from different runtimes on different threads.
mcmasn-amzn
Metadata
Metadata
Assignees
Labels
No labels