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
source(file.InitSession)
}
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
self.lexer.readHeader()
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()
EndOfDataError
Any idea why this happens? I have all directories set at full access. (777)
> R.Version()
$platform
[1] "x86_64-apple-darwin9.8.0"
$arch
[1] "x86_64"
$os
[1] "darwin9.8.0"
$system
[1] "x86_64, darwin9.8.0"
$status
[1] ""
$major
[1] "2"
$minor
[1] "15.2"
$year
[1] "2012"
$month
[1] "10"
$day
[1] "26"
$`svn rev`
[1] "61015"
$language
[1] "R"
$version.string
[1] "R version 2.15.2 (2012-10-26)"
$nickname
[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.