Skip to content

Commit

Permalink
release python gil for arrow and arrow2
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoying committed May 7, 2024
1 parent bec5b1c commit 240716f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions connectorx-python/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ pub fn write_arrow<'py>(
origin_query: Option<String>,
queries: &[CXQuery<String>],
) -> Bound<'py, PyAny> {
let destination = get_arrow(source_conn, origin_query, queries)?;
let rbs = destination.arrow()?;
let ptrs = to_ptrs(rbs);
let ptrs = py.allow_threads(
|| -> Result<(Vec<String>, Vec<Vec<(uintptr_t, uintptr_t)>>), ConnectorXPythonError> {
let destination = get_arrow(source_conn, origin_query, queries)?;
let rbs = destination.arrow()?;
Ok(to_ptrs(rbs))
},
)?;
let obj: PyObject = ptrs.into_py(py);
obj.into_bound(py)
}
Expand Down
10 changes: 7 additions & 3 deletions connectorx-python/src/arrow2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ pub fn write_arrow<'py>(
origin_query: Option<String>,
queries: &[CXQuery<String>],
) -> Bound<'py, PyAny> {
let destination = get_arrow2(source_conn, origin_query, queries)?;
let (rbs, schema) = destination.arrow()?;
let ptrs = to_ptrs(rbs, schema);
let ptrs = py.allow_threads(
|| -> Result<(Vec<String>, Vec<Vec<(uintptr_t, uintptr_t)>>), ConnectorXPythonError> {
let destination = get_arrow2(source_conn, origin_query, queries)?;
let (rbs, schema) = destination.arrow()?;
Ok(to_ptrs(rbs, schema))
},
)?;
let obj: PyObject = ptrs.into_py(py);
obj.into_bound(py)
}
Expand Down

0 comments on commit 240716f

Please sign in to comment.