pysciter icon indicating copy to clipboard operation
pysciter copied to clipboard

How to asynchronously call native function?

Open GirkovArpa opened this issue 2 years ago • 1 comments

How to accomplish the same as the below using Python instead of Rust?


Rust

fn sum_async(&self, x: i32, y: i32, callback: Value) -> () {
    thread::spawn(move || {
        callback.call(None, &make_args!(x + y), None).unwrap();
    });
}

JavaScript

function sum_async(a, b) {
  return new Promise((resolve) => {
    Window.this.xcall('sum_async', a, b, resolve);
  });
}

GirkovArpa avatar Oct 17 '21 05:10 GirkovArpa

Exactly the same: https://docs.python.org/3/library/threading.html

Also there's https://docs.python.org/3/library/asyncio.html

pravic avatar Oct 18 '21 04:10 pravic