Mercurial > public > mercurial-scm > hg
diff rust/hg-pyo3/src/lib.rs @ 52531:4c9e31984b3a
rust-pyo3: exposition of AncestorsIterator
Compared to the early experiments, we have one less `RwLock` in the
wrapping. Still that is somewhat redundant with `UnsafePyLeaked` being
itself some kind of lock.
In the original rust-cpython code, we were borrowing the `RefCell`
with a method that can panic. Instead we are now converting the
`PoisonError` that unlocking a `RwLock` can produce.
Since all methods acquiring the `RwLock` are themselves protected
by the GIL and do not release it before returning, nor do they
leak RwLock guards, there is no risk of contention on these locks
themselves.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Sat, 07 Dec 2024 18:38:37 +0100 |
parents | c2480ac4c5e2 |
children | 0f9ed7e7a71b |
line wrap: on
line diff
--- a/rust/hg-pyo3/src/lib.rs Sat Dec 07 18:24:24 2024 +0100 +++ b/rust/hg-pyo3/src/lib.rs Sat Dec 07 18:38:37 2024 +0100 @@ -1,5 +1,6 @@ use pyo3::prelude::*; +mod ancestors; mod convert_cpython; mod dagops; mod exceptions; @@ -17,6 +18,7 @@ let name: String = m.getattr("__name__")?.extract()?; let dotted_name = format!("mercurial.{}", name); + m.add_submodule(&ancestors::init_module(py, &dotted_name)?)?; m.add_submodule(&dagops::init_module(py, &dotted_name)?)?; m.add("GraphError", py.get_type::<exceptions::GraphError>())?; Ok(())