Skip to content

Commit

Permalink
Release GIL to prevent deadlock with GIL-releasing in ObjectValue::cl…
Browse files Browse the repository at this point in the history
…one().
  • Loading branch information
pythonspeed committed Oct 22, 2024
1 parent bfc9488 commit ef5c7bf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/polars-python/src/dataframe/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ impl PyDataFrame {
Ok(PyDataFrame::new(df))
}

pub fn gather(&self, indices: Wrap<Vec<IdxSize>>) -> PyResult<Self> {
pub fn gather(&self, py: Python, indices: Wrap<Vec<IdxSize>>) -> PyResult<Self> {
let indices = indices.0;
let indices = IdxCa::from_vec("".into(), indices);
let df = self.df.take(&indices).map_err(PyPolarsErr::from)?;
let df = Python::allow_threads(py, || self.df.take(&indices).map_err(PyPolarsErr::from))?;
Ok(PyDataFrame::new(df))
}

pub fn gather_with_series(&self, indices: &PySeries) -> PyResult<Self> {
pub fn gather_with_series(&self, py: Python, indices: &PySeries) -> PyResult<Self> {
let indices = indices.series.idx().map_err(PyPolarsErr::from)?;
let df = self.df.take(indices).map_err(PyPolarsErr::from)?;
let df = Python::allow_threads(py, || self.df.take(indices).map_err(PyPolarsErr::from))?;
Ok(PyDataFrame::new(df))
}

Expand Down

0 comments on commit ef5c7bf

Please sign in to comment.