DDtKey commented on code in PR #12086:
URL: https://github.com/apache/datafusion/pull/12086#discussion_r1726962055
##########
datafusion/common-runtime/src/common.rs:
##########
@@ -60,18 +60,67 @@ 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 if e.is_cancelled() {
+ log::warn!("SpawnedTask was polled during shutdown");
+ e
} 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");
}
Review Comment:
Join error is either `is_panic` or `is_cancelled`.
I'd suggest to simplify this and keep some comment why it's shutdown only:
```rs
// `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.
log::warn!("SpawnedTask was polled during shutdown");
e
}
```
--
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]