From dtenenba at fhcrc.org  Thu Oct 25 19:14:41 2012
From: dtenenba at fhcrc.org (Dan Tenenbaum)
Date: Thu, 25 Oct 2012 10:14:41 -0700
Subject: [Rd] concurrent requests (Rook,
	but I think the question is more general)
In-Reply-To: <50895EAA.50403@rug.nl>
References: <50882FC1.40608@rug.nl>
	<F8B3AAEF-822A-4970-BD6A-AB88FF8E8B9B@r-project.org>
	<50883CD9.1090509@rug.nl>
	<FEE1BFBC-494F-4CA6-BBE8-5F3D4D8559CD@r-project.org>
	<508845EB.2090007@rug.nl>
	<F1CBF6BC-B328-4298-9033-1859F04CD67B@r-project.org>
	<508850F4.8090208@rug.nl>
	<3E5C503F-4CE8-4130-B255-011C20C7D438@r-project.org>
	<50895EAA.50403@rug.nl>
Message-ID: <CAF42j22bBzfeN6=bg8Ovp2YcA7d+HxYA5Zw-zSPrc4K1X-bJfw@mail.gmail.com>

On Thu, Oct 25, 2012 at 8:45 AM, Richard D. Morey <r.d.morey at rug.nl> wrote:
> On 24/10/12 10:55 PM, Simon Urbanek wrote:
>>
>>
>> The point is that you need a separate monitoring process or threads. That
>> process can be R, Rserve or any thing else.
>>
>>
>>
>
> Thanks for the tips. This is what I'm currently contemplating:
>
> 1. Main interface starts in user's R session, and opens up the interface
> (HTML/Javascript using Rook package)
> 2. When analysis starts, Rserve is started, with its own web server, using
> Rook, for status updates
> 3. During analysis, main process calls a callback function which uses
> RSassign() to send progress updates to the Rserve server
> 4. HTML/Javascript interface can connect to the webserver on the Rserve
> server to get status updates
> 5. When analysis is done, use RSshutdown() and RSclose() to clean up.
>
> Does this seem reasonable?
>
> One problem I'm having is that when I start Rook on the Rserve server, the
> webserver does not respond (although it is started). Does Rserve only
> respond to requests on the port assigned for RSclient commands?
>
> Best,
> Richard
>
> Here's an example:
>
> #######################
>
> library(Rserve)
>
> ### This works:
>
> stuff = expression({
>
>   library(Rook)
>   s <- Rhttpd$new()
>   s$add(
>     app=system.file('exampleApps/helloworld.R',package='Rook'),
>     name='hello'
>   )
>   s$start(quiet=TRUE)
>   s$browse(1)
>   print(s$full_url(1))
> })
>
> # This will open the browser to the test app, asking for your name
> eval(stuff)
>
> ### This does not:
>
> Rserve(args="--no-save")
> c <- RSconnect()
> RSassign(c, stuff)
>
> # This opens the browser to the correct URL, but the webserver doesn't
> respond.
> RSeval(c, quote(eval(stuff)))
>
>
> #####
> # cleanup
> RSshutdown(c)
> RSclose(c)
>

This "works" for me if I omit the quote(). I get an error, but the
webapp seems to work. Also, I didn't eval(stuff) locally, only on the
server:

> RSeval(c, eval(stuff))
Loading required package: tools
Loading required package: brew
starting httpd help server ... done
[1] "http://127.0.0.1:15583/custom/hello"
Error in parse(text = paste("{", paste(expr, collapse = "\n"), "}")) :
  <text>:1:8: unexpected '/'
1: { http:/
          ^
> traceback()
3: parse(text = paste("{", paste(expr, collapse = "\n"), "}"))
2: serialize(parse(text = paste("{", paste(expr, collapse = "\n"),
       "}"))[[1]], NULL)
1: RSeval(c, eval(stuff))
> sessionInfo()
R Under development (unstable) (2012-10-23 r61007)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] Rook_1.0-8          brew_1.0-6          Rserve_0.6-8
[4] BiocInstaller_1.9.4

Dan

>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] concurrent requests (Rook, but I think the question is more general)
Dan Tenenbaum