Skip to content

Commit 7087685

Browse files
committed
Improve error handling in spawn_and_wait by aborting future on error
1 parent a7f22dd commit 7087685

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/utils.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,18 @@ where
109109
{
110110
let rt = &get_tokio_runtime().0;
111111
let handle = rt.spawn(fut);
112-
Ok(wait_for_future(py, async {
113-
handle.await.map_err(to_datafusion_err)
114-
})???)
112+
let abort_handle = handle.abort_handle();
113+
114+
match wait_for_future(py, async { handle.await.map_err(to_datafusion_err) }) {
115+
Ok(result) => {
116+
let result = result.map_err(PyDataFusionError::from)?;
117+
result.map_err(PyDataFusionError::from)
118+
}
119+
Err(err) => {
120+
abort_handle.abort();
121+
Err(err.into())
122+
}
123+
}
115124
}
116125

117126
pub(crate) fn parse_volatility(value: &str) -> PyDataFusionResult<Volatility> {

0 commit comments

Comments
 (0)