Bugs item #2776713, was opened at 2009-04-20 16:24
Message generated for change (Comment added) made by xiaoniao
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=2776713&group_id=48422

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: rpy2
Status: Open
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Daniel Yuan (xiaoniao)
Assigned to: lgautier (lgautier)
Summary: ungraceful quit from R

Initial Comment:
I was surprised by the following behavior on quitting an R session in rpy2 
(v2.0.3)

xn...@work:~> python
Python 2.5.2 (r252:60911, Nov 26 2008, 00:44:29) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.robjects as robjects
>>> r = robjects.r
>>> print r('a <- 1')
[1] 1                                         ## : fine
>>> print r('q(save="no")')        ## : problem:
xn...@work:~>                    ## : dumped out of both R and python

Is there a way to quit R and return to the python interpreter?

Thanks.



----------------------------------------------------------------------

Comment By: Daniel Yuan (xiaoniao)
Date: 2009-07-02 09:09

Message:
I found 'setCleanUp' in 'rpy2/rpy/rinterface/', in both '__init__.py' and
'rinterface.c'. Where would I define the callback? I noticed that the call
to 'setCleanup' in '__init__.py' is commented out.

----------------------------------------------------------------------

Comment By: lgautier (lgautier)
Date: 2009-07-02 02:43

Message:
To prevent R from quitting, you can *set a "cleanup" callback* with
setCleanUp.
(to know more, there is unfortunately not more doc than the source code at
the moment)

----------------------------------------------------------------------

Comment By: Daniel Yuan (xiaoniao)
Date: 2009-07-01 23:52

Message:
Sorry to take so long to reply.

I tried the above cmds with build 674 of version 2.1-dev. Unfortunately
python still quits abruptly:

xn...@work:~/tmp/rpy2> python
Python 2.5.2 (r252:60911, Nov 26 2008, 00:44:29) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2.robjects as robjects
>>> r = robjects.r
>>> print r('a <- 1')
[1] 1
>>> print r('q(save="no")')
Bus error
xn...@work:~/tmp/rpy2> 


I think the appropriate behavior would be to print nothing and to render
'r' unavailable while retaining it in the namespace, like a closed File
object or database cursor. 

Ideally one could start another R process by, say, reloading the robjects
module. But first things first.

Thanks.


----------------------------------------------------------------------

Comment By: lgautier (lgautier)
Date: 2009-06-22 17:00

Message:
Version 2.1-dev is providing a callback mechanism to control what is
happening upon R exit.
It is currently experimental, but trying it early may help having it do
what you would like it to do.

----------------------------------------------------------------------

Comment By: Daniel Yuan (xiaoniao)
Date: 2009-04-20 23:40

Message:
ok. But just to be clear, the issue quite definitely dumps me out of the
python interpreter and into the bash shell.

I forgot to mention: this is R v2.8-0.

----------------------------------------------------------------------

Comment By: lgautier (lgautier)
Date: 2009-04-20 22:05

Message:

It's an issue (and will remain so until something get worked out, possibly
using ptr_R_CleanUp() ).

PS: You do not appear to ever "leave the Python interpreter" (so need to
return to it) in your example.
PPS: Bug reports are for bugs, questions are answered on the mailing-list
;-)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=2776713&group_id=48422

------------------------------------------------------------------------------
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to