[racket] server never time out is not good, timeout manager takes down the server after timing out, JS automatically refreshes template pages doesn't work neither-- which way to go?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Sep 10 14:17:57 EDT 2012

I'm not sure what error you're referring to in the second case, unless
you mean that the timeout is shorter than the expected availability of
job A's results, in which case you should expect it to be an error,
because you went over the time limit.

If you used the LRU manager and then combined that with an
auto-updating Javascript refresh, then the browser would continually
give the continuation "life points" and it would never be reclaimed
until it stopped being refreshed and you faced memory pressure.

If you can't rely on Javascript, you could have the server run another
thread that continually called continuation-lookup on your LRU manager
to give it life points directly.

A similar approach would be to write your own manager that associated
continuations with these long-running jobs and only freed them after
the job was completed.

Jay

On Sun, Sep 9, 2012 at 5:13 PM, jenny sun <jenny.sun.jenny.sun at gmail.com> wrote:
> Hi,
>
> I have a problem.
>
> The web application will do some job A, which takes long time, so I make a
> thread to do the job A and make a refresh button for that to pull the result
> back.
>
> However, the problem is that, if A takes long time, the session in the user
> side will be timed out, which A's results can not be accessed.
>
> So I tried three solutions, it seems that none of them can be done easily in
> racket:
>
> Solution 1: make the server never timeout. But this cause too much
> resources.
>
> Solution 2: create a timeout manager specifying some time, like this in
> serve/servlet
>
> #:manager (create-timeout-manager
>                           (lambda (req)
>                             (response/full
>      200 #"Okay"
>      (current-seconds) TEXT/HTML-MIME-TYPE
>      empty
>      (list (string->bytes/utf-8 (include-template
> "templates/timeout.html")))))
>                              3600 3600) ; an hour timeout...
> The problem of this solution is that it will have exception thrown out if
> user trying to access to server if it is timeout. In other words, the server
> will be unavailable entirely if it is timed out, which is undesirable!
>
> Solution 3: write a JS to automatically refresh the web pages to pull the
> result. But the problem is that the template html file is dynamically
> generated, when refreshing, it can not access to all the scoped variables in
> racket to generate a new page!
>
> Therefore, does anyone have idea how to deal with the problems? or suggest
> other solutions suitable for my case?
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.