Skip to content

Commit

Permalink
fetch: fix the nested async runtime caused by block_on()
Browse files Browse the repository at this point in the history
Summary:
Currently, we have two commton `block_on`s:
* 1st block_on is in python bindlings for converting Rust async to sync
* 2nd block_on is in FetchState.fetch_cas()

This diff adds `block_in_place` for the `block_on()` usage inside FetchState.fetch_cas(), so it can be
called in an async runtime.

Reviewed By: quark-zju

Differential Revision: D65861552

fbshipit-source-id: bce677fe86e83db705f31a356829c426ebd743bd
  • Loading branch information
zzl0 authored and facebook-github-bot committed Nov 13, 2024
1 parent 30f9c35 commit 6432c83
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions eden/scm/lib/revisionstore/src/scmstore/tree/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ impl FetchState {
let start_time = Instant::now();
let mut total_stats = CasFetchedStats::default();

block_on(async {
cas_client.fetch(&digests, CasDigestType::Tree).await.for_each(|results| match results {
async_runtime::block_in_place(|| {
block_on(async {
cas_client.fetch(&digests, CasDigestType::Tree).await.for_each(|results| match results {
Ok((stats, results)) => {
reqs += 1;
total_stats.add(&stats);
Expand Down Expand Up @@ -309,6 +310,7 @@ impl FetchState {
future::ready(())
}
}).await;
})
});

span.record("hits", keys_found_count);
Expand Down

0 comments on commit 6432c83

Please sign in to comment.