I should also mention I'm open to other suggestions to alleviate this
problem. The end goal is to display information (text or image) then
request an update, and when it's ready, display the new text/
information.

G

On Aug 24, 11:39 am, G <glenn.calt...@gmail.com> wrote:
> Hi,
> First a little background: My application involves displaying and auto-
> refreshing data both in the form of text from .load components and
> dynamically generated images. I use JavaScript setInterval calls so
> that ideally the refreshes should occur some time after the last
> refresh completes. As it turns out, this does not work for the images
> because using jQuery to update the .attr with the new img src returns
> immediately, not after the image is loaded.
> Anyway, the amount of time required to generate these images and text
> data can be somewhat random, so I'm finding that my site will work for
> a while, but eventually the long duration requests will pile up and
> the site becomes unresponsive. Interestingly, the admin interface is
> still as responsive as usual. I also notice that killing web2py will
> not cause a clean exit, there will still be a thread working furiously
> on the queued requests.
>
> Thus it looks like rocket is using only one thread for the requests on
> the main page, while the other threads sit idle and ready to service
> other pages e.g. the admin interface. I tried to look through the code
> of rocket.py to decide if this is indeed the case, but I wasn't able
> to conclude one way or another. Since the admin interface is still
> responsive, this does not appear to be an issue of the global
> interpreter lock.
>
> I found that starting many web2py servers on different ports, and then
> directing the refresh calls to use a dedicated server for each data
> source alleviated the problem somewhat, further suggesting to me that
> only one thread is being used per session/browser/whatever to call it.
>
> I expect to have no more than 2 users at a time for my application, so
> I was hoping Rocket would be sufficient for this application. Would I
> have better luck with apache or the like? I appreciate any advice on
> the matter.
>
> The code I'm using in the view to refresh the data is listed below
>
> Thank you for the help,
> G
>
> View: --- default/index.html
> ----------------------------
>
> <div id="test3">{{=LOAD('default','calc3.load')}}</div>
> <img id="test2" src="{{=URL('default','calc2.png')}}"></img>
> <img id="test1" src="{{=URL('default','calc1.png')}}"></img>
> <script>
> jQuery(window).load(function()
> {setCalc1Timeout();setCalc2Timeout();setCalc3Timeout()});
>
> function updateCalc3() {
>
> jQuery('#test3').load('{{=URL("default","calc3.load")}}',setCalc3Timeout);
>     }
> function setCalc3Timeout() {
>     setTimeout(updateCalc3, 2000);
>     }
>
> function setCalc2Timeout() {
>         setTimeout(updateCalc2,5000);
>     }
> function updateCalc2() {
>         d = new Date();
>         jQuery('#test2').attr('src',"calc2.png"+"?"+d.getTime());
>         setCalc2Timeout();
>     }
>
> function setCalc1Timeout() {
>         setTimeout(updateCalc1,5000);
>     }
> function updateCalc1() {
>         d = new Date();
>         jQuery('#test1').attr('src',"calc1.png"+"?"+d.getTime());
>         setCalc1Timeout();
>     }
> </script>

Reply via email to