Skip to content

Commit 7206200

Browse files
authored
fix: Revert #22017 and improve block(_in_place)_on doc comment (#22031)
1 parent 3a3b917 commit 7206200

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Diff for: crates/polars-io/src/pl_async.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,20 @@ impl RuntimeManager {
295295
Self { rt }
296296
}
297297

298-
/// Shorthand for `tokio::task::block_in_place(|| block_on(f))`. This is a variant of `block_on`
299-
/// that is safe to call from if the current thread has already entered the async runtime, or
300-
/// is a rayon thread.
301-
///
302-
/// # Safety
303-
/// The tokio runtime flavor is multi-threaded.
298+
/// Forcibly blocks this thread to evaluate the given future. This can be
299+
/// dangerous and lead to deadlocks if called re-entrantly on an async
300+
/// worker thread as the entire thread pool can end up blocking, leading to
301+
/// a deadlock. If you want to prevent this use block_on, which will panic
302+
/// if called from an async thread.
304303
pub fn block_in_place_on<F>(&self, future: F) -> F::Output
305304
where
306305
F: Future,
307306
{
308307
tokio::task::block_in_place(|| self.rt.block_on(future))
309308
}
310309

311-
/// Note: `block_in_place_on` should be used instead if the current thread is a rayon thread or
312-
/// has already entered the async runtime.
310+
/// Blocks this thread to evaluate the given future. Panics if the current
311+
/// thread is an async runtime worker thread.
313312
pub fn block_on<F>(&self, future: F) -> F::Output
314313
where
315314
F: Future,

Diff for: crates/polars-stream/src/execute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ fn run_subgraph(
233233
if std::env::var("POLARS_TRACK_WAIT_STATS").as_deref() == Ok("1") {
234234
async_executor::track_task_wait_statistics(true);
235235
}
236-
let ret = polars_io::pl_async::get_runtime().block_in_place_on(async move {
236+
let ret = polars_io::pl_async::get_runtime().block_on(async move {
237237
for handle in join_handles {
238238
handle.await?;
239239
}

0 commit comments

Comments
 (0)