mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-28 09:24:41 +00:00
Fix db_pool extraction
This commit is contained in:
@@ -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()?;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user