Skip to content

Commit

Permalink
fix(python): fix macros also for client.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ghyatzo committed Sep 8, 2024
1 parent f116f27 commit f2a2892
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/ffi/python/client.rs
Original file line number Diff line number Diff line change
@@ -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<Self> {
fn __new__(
host: String,
username: String,
password: String,
) -> crate::errors::ConnectionResult<Self> {
super::tokio().block_on(Client::connect(host, username, password))
}

Expand All @@ -25,7 +30,7 @@ impl Client {
fn pyjoin_workspace(&self, py: Python<'_>, workspace: String) -> PyResult<super::Promise> {
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
Expand All @@ -39,14 +44,14 @@ impl Client {
fn pycreate_workspace(&self, py: Python<'_>, workspace: String) -> PyResult<super::Promise> {
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<super::Promise> {
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")]
Expand All @@ -58,7 +63,7 @@ impl Client {
) -> PyResult<super::Promise> {
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")]
Expand All @@ -70,7 +75,7 @@ impl Client {
) -> PyResult<super::Promise> {
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")]
Expand Down Expand Up @@ -103,6 +108,6 @@ impl Client {
fn pyrefresh(&self, py: Python<'_>) -> PyResult<super::Promise> {
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)
}
}

0 comments on commit f2a2892

Please sign in to comment.