alamb commented on code in PR #12086:
URL: https://github.com/apache/datafusion/pull/12086#discussion_r1729206001
##########
datafusion/common-runtime/src/common.rs:
##########
@@ -60,18 +60,52 @@ impl<R: 'static> SpawnedTask<R> {
}
/// Joins the task and unwinds the panic if it happens.
- pub async fn join_unwind(self) -> R {
- self.join().await.unwrap_or_else(|e| {
+ pub async fn join_unwind(self) -> Result<R, JoinError> {
+ self.join().await.map_err(|e| {
// `JoinError` can be caused either by panic or cancellation. We
have to handle panics:
if e.is_panic() {
std::panic::resume_unwind(e.into_panic());
} else {
// Cancellation may be caused by two reasons:
// 1. Abort is called, but since we consumed `self`, it's not
our case (`JoinHandle` not accessible outside).
// 2. The runtime is shutting down.
- // So we consider this branch as unreachable.
- unreachable!("SpawnedTask was cancelled unexpectedly");
+ log::warn!("SpawnedTask was polled during shutdown");
+ e
}
})
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ use std::future::{pending, Pending};
+
+ use tokio::runtime::Runtime;
+
Review Comment:
https://github.com/apache/datafusion/pull/12134
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]