Comments (9)
Eventloop was implemented in RCalling.jl and Rif.jl. See for example this link. The code was written in C, however, it should be easy to port it to Julia. I can submit a PR this afternoon.
from rcall.jl.
Please checkout the current master branch for the eventloop. Basically, there are two functions: RCall.rgui_start()
and RCall.rgui_stop()
.
from rcall.jl.
Once we have callbacks sorted out, we could automate this using setHook
.
from rcall.jl.
In the eventloop, there was a dirty fix related to sigint
. The problem was when a sigint
is signaled from Julia (pressing Control - C), the R_interrupts_pending
is set to state 1. Without a proper R eventloop, R_interrupts_pending
remains state 1. And it causes segfault when evaluating R_ProcessEvents
. So R_interrupts_pending
was forced to be 0 in there.
For a while, I only think that it is needed for R_ProcessEvents
. Until just now, I discovered this
julia> using RCall
julia> reval("gc()")
RCall.RObject{RCall.RealSxp}
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 219236 11.8 460000 24.6 350000 18.7
Vcells 322397 2.5 786432 6.0 786432 6.0
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
0
julia> ^C
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
1
julia> reval("gc()")
ERROR: RCall.jl
in error at error.jl:22
in reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:11
in reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:19
in reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:29
in reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:31
julia> unsafe_load(cglobal((:R_interrupts_pending,RCall.libR),Cint))
0
julia> reval("gc()")
signal (11): Segmentation fault: 11
sexp at /Users/Randy/.julia/v0.4/RCall/src/types.jl:332
jlcall_sexp_21406 at (unknown line)
reval_p at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:18
reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:29
jlcall_reval_21501 at (unknown line)
reval at /Users/Randy/.julia/v0.4/RCall/src/iface.jl:31
jl_apply at /opt/local/julia/src/interpreter.c:55
eval at /opt/local/julia/src/interpreter.c:213
jl_toplevel_eval_flex at /opt/local/julia/src/toplevel.c:527
jl_toplevel_eval_in at /opt/local/julia/src/builtins.c:579
eval_user_input at REPL.jl:62
jlcall_eval_user_input_21271 at (unknown line)
anonymous at REPL.jl:92
jl_apply at /opt/local/julia/src/task.c:241
Selection:
But interestingly, if reval("gc()")
is replaced by rcall(:gc)
, it causes no issues.
It means that we might need to check the value of R_interrupts_pending
constantly.
from rcall.jl.
One possible solution is to disable signal handling
if !Rinited
unsafe_store!(cglobal((:R_SignalHandlers,libR),Cint),0)
argv = ["REmbeddedJulia","--silent","--no-save"]
i = ccall((:Rf_initEmbeddedR,libR),Cint,(Cint,Ptr{Ptr{UInt8}}),length(argv),argv)
i > 0 || error("initEmbeddedR failed. Try restarting and running Pkg.build(\"RCall\").")
global const Rproc = Rinstance(i)
end
from rcall.jl.
Though the eventloop implementation is still primitive, I believe this thread could be closed (at least for now).
from rcall.jl.
One thought: in the timer loop we could check if there are any open graphics devices, and if not, close the timer?
from rcall.jl.
If I am correct, the timer loop is also needed for some X11 applications and they are not necessary graphics.
from rcall.jl.
We could create a graphic-specific one (started by a hook), and a general (manual) one?
from rcall.jl.
Related Issues (20)
- why building RCall.jl failed during the registration of an package HOT 2
- RCall.jl failed to build with Conda (23.3.1) HOT 3
- "is.na() applied to non-(list or vector) of type 'language'" when passing a Julia's boolean variable to R's smooth.spline HOT 2
- Unable to Pkg.build RCall HOT 4
- Find the number of arguments for an RFunction? HOT 1
- loading RCall in atreplinit fails because of RPrompt HOT 1
- Error: attempt to apply non-function HOT 5
- [BUG] ArgumentError: malformed expression in formula HOT 3
- If julia functions which was brought to R throws an error, no real error is thrown, but an error object is returned #216 HOT 3
- Feature Request: Add possibility to build RCall without having R_HOME set HOT 3
- ERROR: UndefVarError: `val` not defined
- Segmentation fault on closing julia HOT 7
- equal `==` is not working on `reval` HOT 2
- Feature Request: Make RCall depend dynamically on `R_HOME` HOT 9
- Feature Request: show/display methods for R plots like ggplot2 HOT 3
- Could we add a point in the docs about setting up CI ? HOT 6
- ERROR: REvalError: Loading required package: mvtnorm HOT 1
- Difficulty installing RCall on a low version of julia HOT 6
- Incorrect julia compat HOT 3
- Add support for TimeZones
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcall.jl.