Skip to content

Commit

Permalink
revisionstore: make trees_blocking() can be called in an async runtime
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 EdenApiTreeStore.trees_blocking in Sapling Remote APIs

It is very easy to hit the nested async runtime problem when calling
Sapling Remote APIs in Rust async functions, especially when those functions
exposed to Python with `block_on`.

This diff adds `block_in_place` for the `trees_blocking()` function, so it can be
called in an async runtime.

Reviewed By: quark-zju

Differential Revision: D63612846

fbshipit-source-id: b5843118739c77117591fe32271160114621c654
  • Loading branch information
zzl0 authored and facebook-github-bot committed Oct 14, 2024
1 parent 83ebfef commit 49da327
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eden/scm/lib/revisionstore/src/edenapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ impl SaplingRemoteApiTreeStore {
BlockingResponse<Result<TreeEntry, SaplingRemoteApiServerError>>,
SaplingRemoteApiError,
> {
BlockingResponse::from_async(self.client.trees(keys, attributes))
async_runtime::block_in_place(|| {
BlockingResponse::from_async(self.client.trees(keys, attributes))
})
}
}

Expand Down

0 comments on commit 49da327

Please sign in to comment.