mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
wip(python): try_recv doesn't return a promise.
This commit is contained in:
parent
472c33f734
commit
0c9ea08d64
2 changed files with 30 additions and 9 deletions
15
dist/py/build.sh
vendored
15
dist/py/build.sh
vendored
|
@ -6,17 +6,26 @@ TARGET_EXT="$($PYO3_PYTHON -c 'import sysconfig; print(sysconfig.get_config_var(
|
|||
|
||||
maturin build -i "$PYO3_PYTHON" --out "$WHEEL_DIR"
|
||||
|
||||
CODEMPSUBLIME_DIR="../../../codemp-sublime/bindings/"
|
||||
echo "\nAUTOINSTALL - REMOVE AFTER TESTING\n"
|
||||
|
||||
CODEMPSUBLIME_DIR="../../../codemp-sublime/"
|
||||
CODEMPTEST_DIR="../../../codemp-python-test/"
|
||||
|
||||
wheels=($WHEEL_DIR/*.whl)
|
||||
for wheel in $wheels; do
|
||||
echo "moving $wheel to $CODEMPSUBLIME_DIR"
|
||||
cp $wheel "$CODEMPSUBLIME_DIR"
|
||||
cp $wheel "$CODEMPSUBLIME_DIR/bindings/"
|
||||
cp $wheel "$CODEMPTEST_DIR"
|
||||
done
|
||||
|
||||
cd "$CODEMPSUBLIME_DIR"
|
||||
pushd "$CODEMPTEST_DIR"
|
||||
source .venv/bin/activate
|
||||
pip install $wheel --force-reinstall
|
||||
deactivate
|
||||
popd
|
||||
|
||||
pushd "$CODEMPSUBLIME_DIR"
|
||||
source .venv/bin/activate
|
||||
pip install $wheel --force-reinstall
|
||||
deactivate
|
||||
popd
|
||||
|
|
|
@ -31,16 +31,28 @@ impl CursorController {
|
|||
}
|
||||
|
||||
#[pyo3(name = "try_recv")]
|
||||
fn pytry_recv(&self, py: Python) -> PyResult<Promise> {
|
||||
fn pytry_recv(&self, py: Python) -> PyResult<PyObject> {
|
||||
// why? I want try-recv to have that 'blocking' flavour, for the "cool guy async" approach there's
|
||||
// 'recv'...
|
||||
let this = self.clone();
|
||||
a_sync_allow_threads!(py, this.try_recv().await)
|
||||
let prom: crate::Result<Promise> = a_sync_allow_threads!(py, this.try_recv().await);
|
||||
prom?._await(py)
|
||||
// // bad situation, here we either return an opaque PyResult<PyObject>
|
||||
// // or if we want to return exacly a Result<Option<Cursor>> we would need to extract it back
|
||||
// // into a rust object... which is expensive.
|
||||
// // This is stupid isn't it?
|
||||
// // the PyResult<Option<Cursor>> will become a PyObject anyway to be returned back... lmao
|
||||
// let this = self.clone();
|
||||
// let prom: crate::Result<Promise> = a_sync_allow_threads!(py, this.try_recv().await);
|
||||
// let pyobj = prom?._await(py)?;
|
||||
// let opt = pyobj.extract::<Option<Cursor>>(py)?;
|
||||
// Ok(opt)
|
||||
}
|
||||
|
||||
#[pyo3(name = "recv")]
|
||||
fn pyrecv(&self, py: Python) -> crate::Result<Option<Cursor>> {
|
||||
py.allow_threads(|| super::tokio().block_on(self.try_recv()))
|
||||
// let this = self.clone();
|
||||
// a_sync_allow_threads!(py, this.recv().await)
|
||||
fn pyrecv(&self, py: Python) -> PyResult<Promise> {
|
||||
let this = self.clone();
|
||||
a_sync_allow_threads!(py, this.recv().await)
|
||||
}
|
||||
|
||||
#[pyo3(name = "poll")]
|
||||
|
|
Loading…
Reference in a new issue