From 454a5b23b21cb223cb5a131ac42d74202176ae7e Mon Sep 17 00:00:00 2001 From: smartgoo Date: Wed, 27 Nov 2024 19:31:54 -0500 Subject: [PATCH] connect fn async runtime: --- rpc/wrpc/bindings/python/src/client.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/rpc/wrpc/bindings/python/src/client.rs b/rpc/wrpc/bindings/python/src/client.rs index 8877ade3f..0d2076eb0 100644 --- a/rpc/wrpc/bindings/python/src/client.rs +++ b/rpc/wrpc/bindings/python/src/client.rs @@ -229,15 +229,15 @@ impl RpcClient { } #[pyo3(signature = (block_async_connect=None, strategy=None, url=None, timeout_duration=None, retry_interval=None))] - pub fn connect( + pub fn connect<'py>( &self, - py: Python, + py: Python<'py>, block_async_connect: Option, strategy: Option, url: Option, timeout_duration: Option, retry_interval: Option, - ) -> PyResult> { + ) -> PyResult> { let block_async_connect = block_async_connect.unwrap_or(true); let strategy = match strategy { Some(strategy) => ConnectStrategy::from_str(&strategy).map_err(|err| PyException::new_err(format!("{}", err)))?, @@ -251,10 +251,15 @@ impl RpcClient { self.start_notification_task(py)?; let client = self.inner.client.clone(); - py_async! {py, async move { - let _ = client.connect(Some(options)).await.map_err(|e| PyException::new_err(e.to_string())); + // py_async! {py, async move { + // let _ = client.connect(Some(options)).await.map_err(|e| PyException::new_err(e.to_string()))?; + // Ok(()) + // }} + + pyo3_async_runtimes::tokio::future_into_py(py, async move { + client.connect(Some(options)).await?; Ok(()) - }} + }) } fn disconnect(&self, py: Python) -> PyResult> {