diff --git a/src/io.rs b/src/io.rs index 6c06e85..2fa3915 100644 --- a/src/io.rs +++ b/src/io.rs @@ -275,7 +275,7 @@ use crate::{solve_craft, Recipe, Stats}; /// ``` #[cfg(not(feature = "no_python"))] #[pyfunction] -pub fn solve_from_python(values: &PyAny) -> PyResult>> { +pub fn solve_from_python(py: Python<'_>, values: &PyAny) -> PyResult>> { // Create Recipe let recipe = Recipe { durability: values.getattr("durability")?.extract()?, @@ -304,8 +304,10 @@ pub fn solve_from_python(values: &PyAny) -> PyResult>> }; // println!("{:?} len: {:?} ",values,values.getattr("len()")); - let res = solve_craft(recipe, stats, param); - Ok(res) + py.allow_threads(move || { + let res = solve_craft(recipe, stats, param); + Ok(res) + }) } #[cfg(test)]