diff --git a/src/ffi/python/client.rs b/src/ffi/python/client.rs index e9d63503..93afba7d 100644 --- a/src/ffi/python/client.rs +++ b/src/ffi/python/client.rs @@ -1,11 +1,16 @@ +use super::a_sync_allow_threads; +use super::Client; use crate::workspace::Workspace; -use crate::Client; use pyo3::prelude::*; #[pymethods] impl Client { #[new] - fn __new__(host: String, username: String, password: String) -> crate::errors::ConnectionResult { + fn __new__( + host: String, + username: String, + password: String, + ) -> crate::errors::ConnectionResult { super::tokio().block_on(Client::connect(host, username, password)) } @@ -25,7 +30,7 @@ impl Client { fn pyjoin_workspace(&self, py: Python<'_>, workspace: String) -> PyResult { tracing::info!("attempting to join the workspace {}", workspace); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.join_workspace(workspace).await) + a_sync_allow_threads!(py, this.join_workspace(workspace).await) // let this = self.clone(); // Ok(super::Promise(Some(tokio().spawn(async move { // Ok(this @@ -39,14 +44,14 @@ impl Client { fn pycreate_workspace(&self, py: Python<'_>, workspace: String) -> PyResult { tracing::info!("attempting to create workspace {}", workspace); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.create_workspace(workspace).await) + a_sync_allow_threads!(py, this.create_workspace(workspace).await) } #[pyo3(name = "delete_workspace")] fn pydelete_workspace(&self, py: Python<'_>, workspace: String) -> PyResult { tracing::info!("attempting to delete workspace {}", workspace); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.delete_workspace(workspace).await) + a_sync_allow_threads!(py, this.delete_workspace(workspace).await) } #[pyo3(name = "invite_to_workspace")] @@ -58,7 +63,7 @@ impl Client { ) -> PyResult { tracing::info!("attempting to invite {user} to workspace {workspace}"); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.invite_to_workspace(workspace, user).await) + a_sync_allow_threads!(py, this.invite_to_workspace(workspace, user).await) } #[pyo3(name = "list_workspaces")] @@ -70,7 +75,7 @@ impl Client { ) -> PyResult { tracing::info!("attempting to list workspaces"); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.list_workspaces(owned, invited).await) + a_sync_allow_threads!(py, this.list_workspaces(owned, invited).await) } #[pyo3(name = "leave_workspace")] @@ -103,6 +108,6 @@ impl Client { fn pyrefresh(&self, py: Python<'_>) -> PyResult { tracing::info!("attempting to refresh token"); let this = self.clone(); - crate::a_sync_allow_threads!(py, this.refresh().await) + a_sync_allow_threads!(py, this.refresh().await) } }