Biostrings icon indicating copy to clipboard operation
Biostrings copied to clipboard

Introduce checks for R interrupts in the C code?

Open twmccart opened this issue 4 years ago • 4 comments

Would it be possible to introduce checks for R in the C code? I would like to be able to use some of these functions with R.utils::withTimeout(), but the C code ignores attempts to interrupt it by the user. I think that https://rdrr.io/github/HenrikBengtsson/RNativeAPI/man/R_CheckUserInterrupt.html might be applicable for this.

twmccart avatar Feb 26 '21 20:02 twmccart

Definitely possible. However this is not necessarily as straightforward as it might sound, especially with complicated C code that involves allocating a number of resources. After a user interrupt the code needs to make sure to release all currently allocated resources before returning to R. How to handle this exactly will depend on each situation. Are there any particular functions in Biostrings that you are interested in?

Unfortunately Biostrings has received little attention in the last 5 years because of other priorities and lack of resources. Would you be willing to submit a PR? (Would need to be for one function that you choose, as a start, before going after more functions.)

H.

hpages avatar Feb 26 '21 21:02 hpages

I will try to work on it. The function I care about is findPalindromes(), I will see if I can get it working with that.

twmccart avatar Mar 01 '21 18:03 twmccart

I believe I have this working, but I am not certain that there aren't resources being allocated that I can't see. I have submitted a pull request.

twmccart avatar Mar 05 '21 20:03 twmccart

Okay, there ARE resources being allocated, and I don't have enough knowledge of C to know how to handle them. I'm going to delete that pull request.

twmccart avatar Mar 25 '21 08:03 twmccart

Just checking on the status of this issue--is this still functionality you need? I'll also note that R interrupts are still processed when C code finishes execution, so you should be able to use any C functions with withTimeout as long as the time limit isn't a hard stop time and the Biostrings functions aren't running very slowly. I'd imagine for most use-cases you can have functions timeout within a minute or two of the requested time, but I'm not sure how long it takes findPalindromes to run on your machine.

ahl27 avatar Jun 06 '24 19:06 ahl27

I'm no longer working on that project, so I suppose I don't need it.

twmccart avatar Jun 06 '24 19:06 twmccart

sounds good, in that case I'll close it for now. Feel free to reopen if you experience more issues like this.

ahl27 avatar Jun 07 '24 12:06 ahl27