Skip to content

Commit

Permalink
fixes related to recent tokio changes (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Jan 17, 2022
1 parent 4c81e4a commit f5dbed2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions impls/src/client_utils/client.rs
Expand Up @@ -319,9 +319,13 @@ impl Client {
if Handle::try_current().is_ok() {
let rt = RUNTIME.clone();
let client = self.clone();
std::thread::spawn(move || rt.lock().unwrap().block_on(client.send_request_async(req)))
.join()
.unwrap()
std::thread::spawn(move || {
rt.lock()
.unwrap()
.block_on(async { client.send_request_async(req).await })
})
.join()
.unwrap()
} else {
RUNTIME
.lock()
Expand Down
9 changes: 7 additions & 2 deletions impls/src/node_clients/http.rs
Expand Up @@ -230,6 +230,7 @@ impl NodeClient for HTTPNodeClient {

let url = format!("{}{}", self.node_url(), ENDPOINT);
let api_secret = self.node_api_secret();
let cl = self.client.clone();
let task = async move {
let params: Vec<_> = query_params
.chunks(chunk_size)
Expand All @@ -243,7 +244,7 @@ impl NodeClient for HTTPNodeClient {

let mut tasks = Vec::with_capacity(params.len());
for req in &reqs {
tasks.push(self.client.post_async::<Request, Response>(
tasks.push(cl.post_async::<Request, Response>(
url.as_str(),
req,
api_secret.clone(),
Expand All @@ -254,7 +255,11 @@ impl NodeClient for HTTPNodeClient {
task.try_collect().await
};

let res: Result<Vec<_>, _> = RUNTIME.lock().unwrap().block_on(task);
let rt = RUNTIME.clone();
let res: Result<Vec<_>, _> =
std::thread::spawn(move || rt.lock().unwrap().block_on(async move { task.await }))
.join()
.unwrap();

let results: Vec<OutputPrintable> = match res {
Ok(resps) => {
Expand Down

0 comments on commit f5dbed2

Please sign in to comment.