Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ napi = { version = "2.16", features = ["full"], optional = true }
napi-derive = { version="2.16", optional = true}

# glue (python)
pyo3 = { version = "0.22", features = ["extension-module", "multiple-pymethods"], optional = true}
pyo3 = { version = "0.23", features = ["extension-module", "multiple-pymethods"], optional = true}

# extra
async-trait = { version = "0.1", optional = true }
Expand All @@ -61,7 +61,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
# glue (js)
napi-build = { version = "2.1", optional = true }
# glue (python)
pyo3-build-config = { version = "0.22", optional = true }
pyo3-build-config = { version = "0.23", optional = true }

[features]
default = ["lua-jit", "py-abi3"]
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/python/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ impl BufferController {
}

#[pyo3(name = "ack")]
fn pyack(&self, py: Python, v: Vec<i64>) -> () {
fn pyack(&self, v: Vec<i64>) -> () {
self.ack(v)
}

#[pyo3(name = "send")]
fn pysend(&self, _py: Python, op: TextChange) -> PyResult<()> {
fn pysend(&self, op: TextChange) -> PyResult<()> {
let this = self.clone();
this.send(op)?;
Ok(())
Expand Down
24 changes: 17 additions & 7 deletions src/ffi/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ impl Promise {
macro_rules! a_sync {
($x:expr) => {{
Ok($crate::ffi::python::Promise(Some(
$crate::ffi::python::tokio()
.spawn(async move { Ok($x.map(|f| Python::with_gil(|py| f.into_py(py)))?) }),
$crate::ffi::python::tokio().spawn(async move {
let res = $x?;
Python::with_gil(|py| Ok(res.into_pyobject(py)?.into_any().unbind()))
}),
)))
}};
}
Expand All @@ -95,8 +97,10 @@ macro_rules! a_sync_allow_threads {
($py:ident, $x:expr) => {{
$py.allow_threads(move || {
Ok($crate::ffi::python::Promise(Some(
$crate::ffi::python::tokio()
.spawn(async move { Ok($x.map(|f| Python::with_gil(|py| f.into_py(py)))?) }),
$crate::ffi::python::tokio().spawn(async move {
let res = $x?;
Python::with_gil(|gil| Ok(res.into_pyobject(gil)?.into_any().unbind()))
}),
)))
})
}};
Expand Down Expand Up @@ -236,7 +240,7 @@ impl Selection {
buffer: String,
kwds: Option<&Bound<'_, PyDict>>,
) -> PyResult<Self> {
if let Some(kwds) = kwds {
if let Some(_kwds) = kwds {
Ok(Self {
start_row,
start_col,
Expand Down Expand Up @@ -277,7 +281,7 @@ impl TextChange {
content: String,
kwds: Option<&Bound<'_, PyDict>>,
) -> PyResult<Self> {
if let Some(kwds) = kwds {
if let Some(_kwds) = kwds {
Ok(Self {
start_idx: start,
end_idx: end,
Expand All @@ -300,7 +304,13 @@ impl TextChange {
#[pyfunction]
fn connect(py: Python, config: Py<Config>) -> PyResult<Promise> {
let conf: Config = config.extract(py)?;
a_sync!(Client::connect(conf).await)
Ok(Promise(Some(crate::ffi::python::tokio().spawn(
async move {
let client = Client::connect(conf).await?;
Python::with_gil(|py| Ok(client.into_pyobject(py)?.into_any().unbind()))
},
))))
// a_sync!(Client::connect(conf).await)
}

#[pyfunction]
Expand Down