r-lib / callr

Call R from R
https://callr.r-lib.org/
Other
299 stars 38 forks source link

how to get out of session$attach() #281

Closed venpopov closed 6 months ago

venpopov commented 6 months ago

I ran this code:

library(callr)
sess <- r_session$new()
sess$attach()

which opened an interactive console within the external session. I tested a bit, and typed q() to exist it, which I guess was a mistake, as now my console is completely non-responsive:

> sess$attach()
RS 1018860 > ls()
character(0)
RS 1018860 > a = 1
RS 1018860 > ls()
[1] "a"
RS 1018860 > 
RS 1018860 > q
function (save = "default", status = 0, runLast = TRUE) 
.Internal(quit(save, status, runLast))
<bytecode: 0x55b1affd2158>
<environment: namespace:base>
RS 1018860 > q()
fsdf
1
exit
q

Two questions:

gaborcsardi commented 6 months ago

How do you get out of a console from a session you attached (in general)?

Press CTRL+C, or the stop button in RStudio.

In this case, after having typed q() and my console is unresponsive, what can I do to get back to my original session and console? I am currently running a few background jobs in this Rstudio session, so if I restart the session I will loose the jobs (they've been running for 40ish hours...)

Press CTRL+C, or the stop button in RStudio.

venpopov commented 6 months ago

Neither of these work. There is no red button like usual and ctrl+c has no effect unfortunately

On Mon, Apr 15, 2024, 4:54 PM Gábor Csárdi @.***> wrote:

How do you get out of a console from a session you attached (in general)?

Press CTRL+C, or the stop button in RStudio.

In this case, after having typed q() and my console is unresponsive, what can I do to get back to my original session and console? I am currently running a few background jobs in this Rstudio session, so if I restart the session I will loose the jobs (they've been running for 40ish hours...)

Press CTRL+C, or the stop button in RStudio.

— Reply to this email directly, view it on GitHub https://github.com/r-lib/callr/issues/281#issuecomment-2057057675, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBRCCWSGABY2752BB7NBALY5PS2BAVCNFSM6AAAAABGHP5OQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJXGA2TONRXGU . You are receiving this because you authored the thread.Message ID: @.***>

venpopov commented 6 months ago

If it's relevant, this is in rstudioserver via a browser

gaborcsardi commented 6 months ago

Try pressing ESC while the console is active. How do you usually interrupt a command?

venpopov commented 6 months ago

ESC worked, thank you! I usually interrupt with ctrl+c, and didn't occur to me to try esc when that failed.