diff --git a/crates/stdlib/src/pyexpat.rs b/crates/stdlib/src/pyexpat.rs index 699fa21852d..e96d6287489 100644 --- a/crates/stdlib/src/pyexpat.rs +++ b/crates/stdlib/src/pyexpat.rs @@ -102,7 +102,9 @@ mod _pyexpat { where T: IntoFuncArgs, { - handler.read().call(args, vm).ok(); + // Clone the handler while holding the read lock, then release the lock + let handler = handler.read().clone(); + handler.call(args, vm).ok(); } #[pyclass]