How to asynchronously call native function?
GirkovArpa opened this issue · 1 comments
GirkovArpa commented
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);
});
}
pravic commented
Exactly the same: https://docs.python.org/3/library/threading.html
Also there's https://docs.python.org/3/library/asyncio.html