diff --git a/connectorx-python/src/arrow.rs b/connectorx-python/src/arrow.rs index 0a2be69c0..d8101be18 100644 --- a/connectorx-python/src/arrow.rs +++ b/connectorx-python/src/arrow.rs @@ -16,9 +16,13 @@ pub fn write_arrow<'py>( origin_query: Option, queries: &[CXQuery], ) -> 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, Vec>), 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) } diff --git a/connectorx-python/src/arrow2.rs b/connectorx-python/src/arrow2.rs index 5be62ac80..2a70a3e23 100644 --- a/connectorx-python/src/arrow2.rs +++ b/connectorx-python/src/arrow2.rs @@ -20,9 +20,13 @@ pub fn write_arrow<'py>( origin_query: Option, queries: &[CXQuery], ) -> 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, Vec>), 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) }