From: Jay McCarthy (jay.mccarthy at gmail.com) Date: Tue Sep 11 15:09:01 EDT 2012 |
|
On Mon, Sep 10, 2012 at 5:08 PM, jenny sun <jenny.sun.jenny.sun at gmail.com> wrote: > > > On Mon, Sep 10, 2012 at 8:17 PM, Jay McCarthy <jay.mccarthy at gmail.com> > wrote: >> >> I'm not sure what error you're referring to in the second case, > > > The error as posted on > http://stackoverflow.com/questions/12343071/how-to-make-the-time-out-of-one-connection-of-the-server-while-not-affecting-fol/12355117#12355117.. > I answered there earlier. >> >> 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. > > No. the exception appeared not because that the time to generate A's result > is longer than the timeout limit, it seems that the manager has timed out > the whole server that following requests would fail because of the exception > throwed. > > >> >> >> 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. >> > Thanks for pointing out the LRU manager..do you mean I changed the timeout > manager to LRU manger in the servlet? Yes > But even if I use the LRU manger, can the @syntax in the template page get > their values and have the new page generated, when JS refreshes the > result.html by using windows.location = "result.html" ( and the page that I > want to refresh, e.g. result.html, it uses racket template to dynamically > generate html page) Yup >> >> 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. > > > the continuation-lookup will return a continuation back if all the ids match > on the LRU manger, (which can be pulled out from the servlet I imagined?). > but what do you mean by ''give it life points directly"? The LRU uses a "life point" metaphor for expiring continuations. Basically they get X whenever they are used and lose Y every Z minutes, when they reach 0 they are deleted. >> >> 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. >> > I will see whether it works for the previous two approaches you mentioned > first maybe... > > Maybe there are some dumb questions in this reply because of not really > using these features before, But thanks for your attention, > --Shuying >> >> >> 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 > > -- 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