Open yutannihilation opened 3 weeks ago
WRE suggests R_CheckUserInterrupt()
, but it seems duckdb-r doesn't use it for some reason, which I don't figure out yet. But it seems it's just use csignal.
https://cran.rstudio.com/doc/manuals/r-devel/R-exts.html#Allowing-interrupts
ctrlc crate looks handy.
https://rust-cli.github.io/book/in-depth/signals.html https://github.com/Detegr/rust-ctrlc
This is very useful for me.
The current polars package implements the following, which I believe is not ideal. https://github.com/eitsupi/neo-r-polars/issues/23#issuecomment-2426537409 https://github.com/pola-rs/r-polars/blob/a7b064265f56ece53358955979f929b2cc055c63/src/rust/src/utils/extendr_concurrent.rs#L234-L250
Oh, the current implementation looks very hacky...
I thought we can learn from Python Polars' implementation, but it seems they have their own difficulties...
https://github.com/pola-rs/polars/issues/2687 https://pyo3.rs/v0.22.5/faq#ctrl-c-doesnt-do-anything-while-my-rust-code-is-executing
I think this is the naive translation to Rust, but this doesn't work except for the first Ctrl+C...
https://github.com/yutannihilation/cancel.test.savvy/blob/main/src/rust/src/lib.rs
Some more findings:
eval_parse_text("Sys.sleep(0)")?
on every loop is a workaround.krlmlr/cancel.test
works without such a workaround, probably I'm missing some point
krlmlr/cancel.test
uses cpp11::message
, which evaluates message call, but it works fine without itCalling
eval_parse_text("Sys.sleep(0)")?
on every loop is a workaround.
Other than Sys.sleep
, message()
and warning()
works. However, most functions don't seem to work.
cf.