R function not sourcing from python using pyrserve

Skip to first unread message


Aug 7, 2013, 3:42:21 AM8/7/13
to pyrs...@googlegroups.com
I have a function initSession which is sourced in Rserv.conf when Rserve starts:

    # Function to source session init file. Python calls this for initializing a session.
    initSession <- function(){
    print(file.InitSession) # this works

Within file.InitSession (a .R file) I have a bunch of steps:

    # these are the sample contents of file.InitSession
    print("In init Session script.") ### THIS DOES NOT WORK. DOES NOT PRINT!!
    module = "init_session"
    assign("PID__", PROCESSID__, envir = .GlobalEnv) #PROCESSID__ is var created in R using pyrserve
    # and other statements

In python it spits out this error:

    Traceback (most recent call last):
      File "/opt/insightjedi/django-code/Statistics/rConnectors.py", line 53, in init_R_Session
        self.rConnection.eval("initSession()")  ## ----- added line
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rconn.py", line 37, in decoCheckIfClosed
        return func(self, *args, **kw)
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rconn.py", line 103, in eval
        return rparse(src, atomicArray=atomicArray)
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 469, in rparse
        return rparser.parse()
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 304, in parse
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 83, in readHeader
        self.responseCode = struct.unpack(b'<i', self.read(3) + b'\x00')[0]
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 128, in read
        raise EndOfDataError()

Any idea why this happens? I have all directories set at full access. (777)

    > R.Version()
    [1] "x86_64-apple-darwin9.8.0"
    [1] "x86_64"
    [1] "darwin9.8.0"
    [1] "x86_64, darwin9.8.0"
    [1] ""
    [1] "2"
    [1] "15.2"
    [1] "2012"
    [1] "10"
    [1] "26"
    $`svn rev`
    [1] "61015"
    [1] "R"
    [1] "R version 2.15.2 (2012-10-26)"
    [1] "Trick or Treat"

pyRserve version 0.7.1

And I really hope someone creates a pyRserve tag with reputation>1500. I cant and my guess is questions get all routed to as python questions. Even if you have to copy and paste my question, that is fine.

Ralph Heinkel

Aug 7, 2013, 4:38:41 AM8/7/13
to pyrs...@googlegroups.com
Hi jediinsights,

trying to reproduce your problem. For me it seems to work fine, but I'm not sure about your exact setup. Can you send me a minimalistic R file which is sourced at Rserve startup (including the Rserv.conf entry), and a minimalistic R file which is then sourced by Python and then causes your problems?



Aug 8, 2013, 9:59:43 AM8/8/13
to pyrs...@googlegroups.com
Hi Ralph:
I will post details about how to reproduce the problem shortly.
Reply all
Reply to author
0 new messages