Fix db_pool extraction

This commit is contained in:
Eric Eastwood
2026-06-05 14:32:01 -05:00
parent 66a1886dc7
commit 7757712ebc
2 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -22,6 +22,7 @@ use pyo3::{
use crate::config::SynapseConfig;
use crate::storage::db::python_db_pool::PythonDatabasePool;
use crate::storage::store::Store;
use crate::UnwrapInfallible;
pub mod versions;
@@ -42,7 +43,6 @@ impl RustHandlers {
.call_method0("get_datastores")?
.into_pyobject(py)
.unwrap_infallible()
.unbind()
.getattr("main")?
.getattr("db_pool")?
.extract()?;
+12 -3
View File
@@ -37,7 +37,18 @@ impl DatabaseEngine {
/// Wrapper for a `DatabasePool` from the Python side of Synapse.
pub struct PythonDatabasePool {
/// The underlying `DatabasePool`
database_pool_py: Bound<'py, PyAny>,
database_pool_py: Py<PyAny>,
}
impl<'a, 'py> FromPyObject<'a, 'py> for PythonDatabasePool {
type Error = PyErr;
/// Extract from a Python `DatabasePool` passed as an argument.
fn extract(database_pool_py: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
Ok(Self {
database_pool_py: database_pool_py.to_owned().unbind(),
})
}
}
#[async_trait::async_trait]
@@ -151,8 +162,6 @@ impl<'a, 'py> FromPyObject<'a, 'py> for LoggingTransactionWrapper {
type Error = PyErr;
/// Extract from a Python `LoggingTransaction` passed as an argument.
///
/// The resulting wrapper has `done_tx = None`; Python owns the transaction lifetime.
fn extract(logging_transaction_py: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
let database_engine = detect_engine(&logging_transaction_py.to_owned())?;
Ok(Self {