You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
util: ensure wait_for can only be used in a non-async runtime
Previously, `wait_for` would deadlock when used in an async runtime (ie. any async function calls `wait_for` directly or indirectly). Now, `wait_for` returns an error if called in an async runtime. There's no reason to call it in an async runtime / function because you can simply await the future. This change updates a few places where `wait_for` is called to be async functions and just wait on the future.
Why did the old `Spawner` deadlock? `Handle::current().block_on(f)` and the `std::sync::mpsc::channel` would both block an executor thread in tokio (this is a very bad practice generally). If there's no executer threads available, you can't run anything. Now, the closure just does `f.await` instead of `block_on`, which does not block an executor. The channel is now a `tokio::sync::mpsc::channel` as well with a buffer size of 1, so the async send will not block (I think a buffered std channel would have worked, but it's better to use tokio implementations generally). The receiver of the channel is in a sync runtime, so it does a blocking receive.
Testing
- unit tests now pass
- added a unit test for `wait_for` returning an error in an async runtime
- test for nested `wait_for` calls which now return an error
Closes https://github.com/datafusion-contrib/datafusion-distributed/issues/63
0 commit comments