demonstrate switching to Bound API resolves gevent crash

This commit is contained in:
David Hewitt 2023-12-23 22:10:01 +00:00
parent 46fa1b2b80
commit 49d7718823

View file

@ -18,7 +18,11 @@ fn accepts_bool(val: bool) -> bool {
}
#[pyfunction]
fn get_item_and_run_callback(dict: &PyDict, callback: &PyAny) -> PyResult<()> {
fn get_item_and_run_callback(dict: Bound<'_, PyDict>, callback: Bound<'_, PyAny>) -> PyResult<()> {
// This function gives the opportunity to run a pure-Python callback so that
// gevent can instigate a context switch. This had problematic interactions
// with PyO3's removed "GIL Pool".
// For context, see https://github.com/PyO3/pyo3/issues/3668
let item = dict.get_item("key")?.expect("key not found in dict");
let string = item.to_string();
callback.call0()?;