release the GIL during a DB request

This commit is contained in:
Damien Elmes 2020-03-06 12:30:19 +10:00
parent 90de4a267d
commit daaf8bdc70

View file

@ -76,11 +76,12 @@ impl Backend {
fn db_command(&mut self, py: Python, input: &PyBytes) -> PyResult<PyObject> {
let in_bytes = input.as_bytes();
let out_string = self
.backend
.db_command(in_bytes)
.map_err(|e| DBError::py_err(e.localized_description(&self.backend.i18n())))?;
let out_res = py.allow_threads(move || {
self.backend
.db_command(in_bytes)
.map_err(|e| DBError::py_err(e.localized_description(&self.backend.i18n())))
});
let out_string = out_res?;
let out_obj = PyBytes::new(py, out_string.as_bytes());
Ok(out_obj.into())
}