///
/// Calling `wait()` in the context of a @goal_rule blocks a thread that is owned by the tokio
/// runtime. To do that safely, we need to relinquish it.
///   see https://github.com/pantsbuild/pants/issues/9476
///
/// TODO: The alternative to blocking the runtime would be to have the Python code `await` special
/// methods for things like `materialize_directories` and etc.
///
Calling `wait()` in the context of a @goal_rule blocks a thread that is owned by the tokio
runtime. To do that safely, we need to relinquish it.

The alternative to blocking the runtime would be to have the Python code `await` special
methods for things like `materialize_directories` and etc.
Calling ` wait () ` in the context of a @goal_rule blocks a thread that is owned by the tokio runtime . To do that safely we need to relinquish it . The alternative to blocking the runtime would be to have the Python code ` await ` special methods for things like ` materialize_directories ` and etc .
fn block_in_place_and_wait<T, E, F>(py: Python, f: impl FnOnce() -> F + Sync + Send) -> Result<T, E>
where
  F: Future<Item = T, Error = E>,
{
  py.allow_threads(|| {
    let future = f();
    tokio::task::block_in_place(|| future.wait())
  })
}
fn block_in_place_and_wait < T , E , F > ( py : Python , f : impl FnOnce ( ) -> F + Sync + Send ) -> Result < T , E > where F : Future < Item = T , Error = E > , { py . allow_threads ( | | { let future = f ( ) ; tokio :: task :: block_in_place ( | | future . wait ( ) ) } ) }
Calling `wait()` in the context of a @goal_rule blocks a thread that is owned by the tokio
runtime.
Calling ` wait () ` in the context of a @goal_rule blocks a thread that is owned by the tokio runtime .
py
Python
f
impl FnOnce() -> F + Sync + Send